blob: e9f1a6ac5a6a2cc9bee1e7efee13ac54c2998182 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
//===--- SharedPtrArrayMismatchCheck.h - clang-tidy -------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SMARTPTRARRAYMISMATCHCHECK_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SMARTPTRARRAYMISMATCHCHECK_H
#include "../ClangTidyCheck.h"
namespace clang::tidy::bugprone {
/// Find constructions of smart (unique or shared) pointers where the pointer
/// is declared with non-array target type and an array (created with a
/// new-expression) is passed to it.
class SmartPtrArrayMismatchCheck : public ClangTidyCheck {
public:
SmartPtrArrayMismatchCheck(StringRef Name, ClangTidyContext *Context,
StringRef SmartPointerName);
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
return LangOpts.CPlusPlus11;
}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
protected:
using SmartPtrClassMatcher = ast_matchers::internal::BindableMatcher<Decl>;
/// Returns matcher that match with different smart pointer classes.
///
/// Requires to bind pointer type (qualType) with PointerTypeN string declared
/// in this class.
virtual SmartPtrClassMatcher getSmartPointerClassMatcher() const = 0;
static const char PointerTypeN[];
private:
StringRef const SmartPointerName;
};
} // namespace clang::tidy::bugprone
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SMARTPTRARRAYMISMATCHCHECK_H
|