[clang-tools-extra] ca4485d - [clang-tidy] Simplify const params check
Stephen Kelly via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 17 02:20:35 PST 2021
Author: Stephen Kelly
Date: 2021-02-17T10:20:12Z
New Revision: ca4485d9fc3449f7bb9522ee16ccf63f2219732c
URL: https://github.com/llvm/llvm-project/commit/ca4485d9fc3449f7bb9522ee16ccf63f2219732c
DIFF: https://github.com/llvm/llvm-project/commit/ca4485d9fc3449f7bb9522ee16ccf63f2219732c.diff
LOG: [clang-tidy] Simplify const params check
Differential Revision: https://reviews.llvm.org/D96141
Added:
Modified:
clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp
clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.h
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp b/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp
index aed01ab7ae7c..d35cc079d78a 100644
--- a/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp
+++ b/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp
@@ -33,14 +33,6 @@ void AvoidConstParamsInDecls::registerMatchers(MatchFinder *Finder) {
parmVarDecl(hasType(qualType(isConstQualified()))).bind("param");
Finder->addMatcher(
functionDecl(unless(isDefinition()),
- // Lambdas are always their own definition, but they
- // generate a non-definition FunctionDecl too. Ignore those.
- // Class template instantiations have a non-definition
- // CXXMethodDecl for methods that aren't used in this
- // translation unit. Ignore those, as the template will have
- // already been checked.
- unless(cxxMethodDecl(ofClass(cxxRecordDecl(anyOf(
- isLambda(), ast_matchers::isTemplateInstantiation()))))),
has(typeLoc(forEach(ConstParamDecl))))
.bind("func"),
this);
diff --git a/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.h b/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.h
index 08aac949f98e..d366949e4a16 100644
--- a/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.h
+++ b/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.h
@@ -24,6 +24,9 @@ class AvoidConstParamsInDecls : public ClangTidyCheck {
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+ llvm::Optional<TraversalKind> getCheckTraversalKind() const override {
+ return TK_IgnoreUnlessSpelledInSource;
+ }
};
} // namespace readability
More information about the cfe-commits
mailing list