File tree Expand file tree Collapse file tree 22 files changed +62
-48
lines changed Expand file tree Collapse file tree 22 files changed +62
-48
lines changed Original file line number Diff line number Diff line change @@ -105,10 +105,7 @@ void BracesAroundStatementsCheck::storeOptions(
105
105
}
106
106
107
107
void BracesAroundStatementsCheck::registerMatchers (MatchFinder *Finder) {
108
- Finder->addMatcher (
109
- ifStmt (unless (allOf (isConstexpr (), isInTemplateInstantiation ())))
110
- .bind (" if" ),
111
- this );
108
+ Finder->addMatcher (ifStmt ().bind (" if" ), this );
112
109
Finder->addMatcher (whileStmt ().bind (" while" ), this );
113
110
Finder->addMatcher (doStmt ().bind (" do" ), this );
114
111
Finder->addMatcher (forStmt ().bind (" for" ), this );
Original file line number Diff line number Diff line change @@ -55,6 +55,9 @@ class BracesAroundStatementsCheck : public ClangTidyCheck {
55
55
template <typename IfOrWhileStmt>
56
56
SourceLocation findRParenLoc (const IfOrWhileStmt *S, const SourceManager &SM,
57
57
const ASTContext *Context);
58
+ llvm::Optional<TraversalKind> getCheckTraversalKind () const override {
59
+ return TK_IgnoreUnlessSpelledInSource;
60
+ }
58
61
59
62
private:
60
63
std::set<const Stmt *> ForceBracesStmts;
Original file line number Diff line number Diff line change @@ -171,8 +171,7 @@ void ElseAfterReturnCheck::registerPPCallbacks(const SourceManager &SM,
171
171
void ElseAfterReturnCheck::registerMatchers (MatchFinder *Finder) {
172
172
const auto InterruptsControlFlow = stmt (anyOf (
173
173
returnStmt ().bind (InterruptingStr), continueStmt ().bind (InterruptingStr),
174
- breakStmt ().bind (InterruptingStr),
175
- expr (ignoringImplicit (cxxThrowExpr ().bind (InterruptingStr)))));
174
+ breakStmt ().bind (InterruptingStr), cxxThrowExpr ().bind (InterruptingStr)));
176
175
Finder->addMatcher (
177
176
compoundStmt (
178
177
forEach (ifStmt (unless (isConstexpr ()),
Original file line number Diff line number Diff line change @@ -28,6 +28,9 @@ class ElseAfterReturnCheck : public ClangTidyCheck {
28
28
Preprocessor *ModuleExpanderPP) override ;
29
29
void registerMatchers (ast_matchers::MatchFinder *Finder) override ;
30
30
void check (const ast_matchers::MatchFinder::MatchResult &Result) override ;
31
+ llvm::Optional<TraversalKind> getCheckTraversalKind () const override {
32
+ return TK_IgnoreUnlessSpelledInSource;
33
+ }
31
34
32
35
using ConditionalBranchMap =
33
36
llvm::DenseMap<FileID, SmallVector<SourceRange, 1 >>;
Original file line number Diff line number Diff line change @@ -294,8 +294,7 @@ void InconsistentDeclarationParameterNameCheck::storeOptions(
294
294
295
295
void InconsistentDeclarationParameterNameCheck::registerMatchers (
296
296
MatchFinder *Finder) {
297
- Finder->addMatcher (functionDecl (unless (isImplicit ()), hasOtherDeclarations ())
298
- .bind (" functionDecl" ),
297
+ Finder->addMatcher (functionDecl (hasOtherDeclarations ()).bind (" functionDecl" ),
299
298
this );
300
299
}
301
300
Original file line number Diff line number Diff line change @@ -33,6 +33,9 @@ class InconsistentDeclarationParameterNameCheck : public ClangTidyCheck {
33
33
void storeOptions (ClangTidyOptions::OptionMap &Opts) override ;
34
34
void registerMatchers (ast_matchers::MatchFinder *Finder) override ;
35
35
void check (const ast_matchers::MatchFinder::MatchResult &Result) override ;
36
+ llvm::Optional<TraversalKind> getCheckTraversalKind () const override {
37
+ return TK_IgnoreUnlessSpelledInSource;
38
+ }
36
39
37
40
private:
38
41
void markRedeclarationsAsVisited (const FunctionDecl *FunctionDeclaration);
Original file line number Diff line number Diff line change @@ -106,11 +106,7 @@ void MisleadingIndentationCheck::missingBracesCheck(const SourceManager &SM,
106
106
}
107
107
108
108
void MisleadingIndentationCheck::registerMatchers (MatchFinder *Finder) {
109
- Finder->addMatcher (
110
- ifStmt (allOf (hasElse (stmt ()),
111
- unless (allOf (isConstexpr (), isInTemplateInstantiation ()))))
112
- .bind (" if" ),
113
- this );
109
+ Finder->addMatcher (ifStmt (hasElse (stmt ())).bind (" if" ), this );
114
110
Finder->addMatcher (
115
111
compoundStmt (has (stmt (anyOf (ifStmt (), forStmt (), whileStmt ()))))
116
112
.bind (" compound" ),
Original file line number Diff line number Diff line change @@ -27,6 +27,9 @@ class MisleadingIndentationCheck : public ClangTidyCheck {
27
27
: ClangTidyCheck(Name, Context) {}
28
28
void registerMatchers (ast_matchers::MatchFinder *Finder) override ;
29
29
void check (const ast_matchers::MatchFinder::MatchResult &Result) override ;
30
+ llvm::Optional<TraversalKind> getCheckTraversalKind () const override {
31
+ return TK_IgnoreUnlessSpelledInSource;
32
+ }
30
33
31
34
private:
32
35
void danglingElseCheck (const SourceManager &SM, ASTContext *Context,
Original file line number Diff line number Diff line change @@ -18,18 +18,14 @@ namespace tidy {
18
18
namespace readability {
19
19
20
20
void NamedParameterCheck::registerMatchers (ast_matchers::MatchFinder *Finder) {
21
- Finder->addMatcher (functionDecl (unless ( isInstantiated ()) ).bind (" decl" ), this );
21
+ Finder->addMatcher (functionDecl ().bind (" decl" ), this );
22
22
}
23
23
24
24
void NamedParameterCheck::check (const MatchFinder::MatchResult &Result) {
25
25
const SourceManager &SM = *Result.SourceManager ;
26
26
const auto *Function = Result.Nodes .getNodeAs <FunctionDecl>(" decl" );
27
27
SmallVector<std::pair<const FunctionDecl *, unsigned >, 4 > UnnamedParams;
28
28
29
- // Ignore implicitly generated members.
30
- if (Function->isImplicit ())
31
- return ;
32
-
33
29
// Ignore declarations without a definition if we're not dealing with an
34
30
// overriden method.
35
31
const FunctionDecl *Definition = nullptr ;
Original file line number Diff line number Diff line change @@ -32,6 +32,9 @@ class NamedParameterCheck : public ClangTidyCheck {
32
32
: ClangTidyCheck(Name, Context) {}
33
33
void registerMatchers (ast_matchers::MatchFinder *Finder) override ;
34
34
void check (const ast_matchers::MatchFinder::MatchResult &Result) override ;
35
+ llvm::Optional<TraversalKind> getCheckTraversalKind () const override {
36
+ return TK_IgnoreUnlessSpelledInSource;
37
+ }
35
38
};
36
39
37
40
} // namespace readability
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ namespace readability {
18
18
19
19
void NonConstParameterCheck::registerMatchers (MatchFinder *Finder) {
20
20
// Add parameters to Parameters.
21
- Finder->addMatcher (parmVarDecl (unless ( isInstantiated ()) ).bind (" Parm" ), this );
21
+ Finder->addMatcher (parmVarDecl ().bind (" Parm" ), this );
22
22
23
23
// C++ constructor.
24
24
Finder->addMatcher (cxxConstructorDecl ().bind (" Ctor" ), this );
@@ -28,13 +28,11 @@ void NonConstParameterCheck::registerMatchers(MatchFinder *Finder) {
28
28
Finder->addMatcher (declRefExpr ().bind (" Ref" ), this );
29
29
30
30
// Analyse parameter usage in function.
31
- Finder->addMatcher (
32
- traverse (TK_AsIs,
33
- stmt (anyOf (unaryOperator (hasAnyOperatorName (" ++" , " --" )),
34
- binaryOperator (), callExpr (), returnStmt (),
35
- cxxConstructExpr ()))
36
- .bind (" Mark" )),
37
- this );
31
+ Finder->addMatcher (stmt (anyOf (unaryOperator (hasAnyOperatorName (" ++" , " --" )),
32
+ binaryOperator (), callExpr (), returnStmt (),
33
+ cxxConstructExpr ()))
34
+ .bind (" Mark" ),
35
+ this );
38
36
Finder->addMatcher (varDecl (hasInitializer (anything ())).bind (" Mark" ), this );
39
37
}
40
38
Original file line number Diff line number Diff line change @@ -26,6 +26,9 @@ class NonConstParameterCheck : public ClangTidyCheck {
26
26
void registerMatchers (ast_matchers::MatchFinder *Finder) override ;
27
27
void check (const ast_matchers::MatchFinder::MatchResult &Result) override ;
28
28
void onEndOfTranslationUnit () override ;
29
+ llvm::Optional<TraversalKind> getCheckTraversalKind () const override {
30
+ return TK_IgnoreUnlessSpelledInSource;
31
+ }
29
32
30
33
private:
31
34
// / Parameter info.
Original file line number Diff line number Diff line change @@ -32,10 +32,10 @@ bool isLocationInMacroExpansion(const SourceManager &SM, SourceLocation Loc) {
32
32
33
33
void RedundantControlFlowCheck::registerMatchers (MatchFinder *Finder) {
34
34
Finder->addMatcher (
35
- functionDecl (
36
- isDefinition (), returns ( voidType ()),
37
- has ( compoundStmt ( hasAnySubstatement ( returnStmt (unless (has (expr ())))))
38
- .bind (" return" ))),
35
+ functionDecl (isDefinition (), returns ( voidType ()),
36
+ hasBody ( compoundStmt ( hasAnySubstatement (
37
+ returnStmt (unless (has (expr ())))))
38
+ .bind (" return" ))),
39
39
this );
40
40
Finder->addMatcher (
41
41
mapAnyOf (forStmt, cxxForRangeStmt, whileStmt, doStmt)
Original file line number Diff line number Diff line change @@ -29,6 +29,10 @@ class RedundantControlFlowCheck : public ClangTidyCheck {
29
29
void registerMatchers (ast_matchers::MatchFinder *Finder) override ;
30
30
void check (const ast_matchers::MatchFinder::MatchResult &Result) override ;
31
31
32
+ llvm::Optional<TraversalKind> getCheckTraversalKind () const override {
33
+ return TK_IgnoreUnlessSpelledInSource;
34
+ }
35
+
32
36
private:
33
37
void
34
38
checkRedundantReturn (const ast_matchers::MatchFinder::MatchResult &Result,
Original file line number Diff line number Diff line change @@ -32,15 +32,15 @@ void SimplifySubscriptExprCheck::registerMatchers(MatchFinder *Finder) {
32
32
llvm::SmallVector<StringRef, 8 >(Types.begin (), Types.end ()))))));
33
33
34
34
Finder->addMatcher (
35
- arraySubscriptExpr (hasBase (ignoringParenImpCasts (
35
+ arraySubscriptExpr (hasBase (
36
36
cxxMemberCallExpr (
37
37
has (memberExpr ().bind (" member" )),
38
38
on (hasType (qualType (
39
39
unless (anyOf (substTemplateTypeParmType (),
40
40
hasDescendant (substTemplateTypeParmType ()))),
41
41
anyOf (TypesMatcher, pointerType (pointee (TypesMatcher)))))),
42
42
callee (namedDecl (hasName (" data" ))))
43
- .bind (" call" )))) ,
43
+ .bind (" call" ))),
44
44
this );
45
45
}
46
46
Original file line number Diff line number Diff line change @@ -28,6 +28,9 @@ class SimplifySubscriptExprCheck : public ClangTidyCheck {
28
28
void registerMatchers (ast_matchers::MatchFinder *Finder) override ;
29
29
void check (const ast_matchers::MatchFinder::MatchResult &Result) override ;
30
30
void storeOptions (ClangTidyOptions::OptionMap& Opts) override ;
31
+ llvm::Optional<TraversalKind> getCheckTraversalKind () const override {
32
+ return TK_IgnoreUnlessSpelledInSource;
33
+ }
31
34
32
35
private:
33
36
const std::vector<std::string> Types;
Original file line number Diff line number Diff line change @@ -39,8 +39,7 @@ void StaticAccessedThroughInstanceCheck::storeOptions(
39
39
void StaticAccessedThroughInstanceCheck::registerMatchers (MatchFinder *Finder) {
40
40
Finder->addMatcher (
41
41
memberExpr (hasDeclaration (anyOf (cxxMethodDecl (isStaticStorageClass ()),
42
- varDecl (hasStaticStorageDuration ()))),
43
- unless (isInTemplateInstantiation ()))
42
+ varDecl (hasStaticStorageDuration ()))))
44
43
.bind (" memberExpression" ),
45
44
this );
46
45
}
Original file line number Diff line number Diff line change @@ -30,6 +30,9 @@ class StaticAccessedThroughInstanceCheck : public ClangTidyCheck {
30
30
void storeOptions (ClangTidyOptions::OptionMap &Opts) override ;
31
31
void registerMatchers (ast_matchers::MatchFinder *Finder) override ;
32
32
void check (const ast_matchers::MatchFinder::MatchResult &Result) override ;
33
+ llvm::Optional<TraversalKind> getCheckTraversalKind () const override {
34
+ return TK_IgnoreUnlessSpelledInSource;
35
+ }
33
36
34
37
private:
35
38
const unsigned NameSpecifierNestingThreshold;
Original file line number Diff line number Diff line change @@ -39,17 +39,14 @@ void UniqueptrDeleteReleaseCheck::registerMatchers(MatchFinder *Finder) {
39
39
Finder->addMatcher (
40
40
cxxDeleteExpr (
41
41
unless (isInTemplateInstantiation ()),
42
- has (expr (ignoringParenImpCasts (
43
- cxxMemberCallExpr (
44
- callee (
45
- memberExpr (hasObjectExpression (allOf (
46
- unless (isTypeDependent ()),
47
- anyOf (hasType (UniquePtrWithDefaultDelete),
48
- hasType (pointsTo (
49
- UniquePtrWithDefaultDelete))))),
50
- member (cxxMethodDecl (hasName (" release" ))))
51
- .bind (" release_expr" )))
52
- .bind (" release_call" )))))
42
+ has (cxxMemberCallExpr (
43
+ callee (memberExpr (hasObjectExpression (anyOf (
44
+ hasType (UniquePtrWithDefaultDelete),
45
+ hasType (pointsTo (
46
+ UniquePtrWithDefaultDelete)))),
47
+ member (cxxMethodDecl (hasName (" release" ))))
48
+ .bind (" release_expr" )))
49
+ .bind (" release_call" )))
53
50
.bind (" delete" ),
54
51
this );
55
52
}
Original file line number Diff line number Diff line change @@ -26,6 +26,9 @@ class UniqueptrDeleteReleaseCheck : public ClangTidyCheck {
26
26
void registerMatchers (ast_matchers::MatchFinder *Finder) override ;
27
27
void check (const ast_matchers::MatchFinder::MatchResult &Result) override ;
28
28
void storeOptions (ClangTidyOptions::OptionMap &Opts) override ;
29
+ llvm::Optional<TraversalKind> getCheckTraversalKind () const override {
30
+ return TK_IgnoreUnlessSpelledInSource;
31
+ }
29
32
30
33
private:
31
34
const bool PreferResetCall;
Original file line number Diff line number Diff line change @@ -196,12 +196,11 @@ void UppercaseLiteralSuffixCheck::registerMatchers(MatchFinder *Finder) {
196
196
// Sadly, we can't check whether the literal has suffix or not.
197
197
// E.g. i32 suffix still results in 'BuiltinType::Kind::Int'.
198
198
// And such an info is not stored in the *Literal itself.
199
- Finder->addMatcher (traverse (TK_AsIs,
199
+ Finder->addMatcher (
200
200
stmt (eachOf (integerLiteral ().bind (IntegerLiteralCheck::Name),
201
201
floatLiteral ().bind (FloatingLiteralCheck::Name)),
202
202
unless (anyOf (hasParent (userDefinedLiteral ()),
203
- hasAncestor (isImplicit ()),
204
- hasAncestor (substNonTypeTemplateParmExpr ()))))),
203
+ hasAncestor (substNonTypeTemplateParmExpr ())))),
205
204
this );
206
205
}
207
206
Original file line number Diff line number Diff line change @@ -28,6 +28,9 @@ class UppercaseLiteralSuffixCheck : public ClangTidyCheck {
28
28
void registerMatchers (ast_matchers::MatchFinder *Finder) override ;
29
29
void check (const ast_matchers::MatchFinder::MatchResult &Result) override ;
30
30
void storeOptions (ClangTidyOptions::OptionMap &Opts) override ;
31
+ llvm::Optional<TraversalKind> getCheckTraversalKind () const override {
32
+ return TK_IgnoreUnlessSpelledInSource;
33
+ }
31
34
32
35
private:
33
36
template <typename LiteralType>
You can’t perform that action at this time.
0 commit comments