[clang-tools-extra] 9ba557c - [clang-tidy] Simplify default member init check
Stephen Kelly via cfe-commits
cfe-commits at lists.llvm.org
Sat Feb 27 04:15:15 PST 2021
Author: Stephen Kelly
Date: 2021-02-27T12:11:43Z
New Revision: 9ba557cc0370ee5fa93dca04a20bd2b05bf19f45
URL: https://github.com/llvm/llvm-project/commit/9ba557cc0370ee5fa93dca04a20bd2b05bf19f45
DIFF: https://github.com/llvm/llvm-project/commit/9ba557cc0370ee5fa93dca04a20bd2b05bf19f45.diff
LOG: [clang-tidy] Simplify default member init check
Differential Revision: https://reviews.llvm.org/D97145
Added:
Modified:
clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.h
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
index 9ce56d953c9e..6e7e37236b19 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -207,14 +207,13 @@ void UseDefaultMemberInitCheck::registerMatchers(MatchFinder *Finder) {
declRefExpr(to(enumConstantDecl())));
auto Init =
- anyOf(initListExpr(anyOf(
- allOf(initCountIs(1), hasInit(0, ignoringImplicit(InitBase))),
- initCountIs(0))),
+ anyOf(initListExpr(anyOf(allOf(initCountIs(1), hasInit(0, InitBase)),
+ initCountIs(0))),
InitBase);
Finder->addMatcher(
cxxConstructorDecl(
- isDefaultConstructor(), unless(isInstantiated()),
+ isDefaultConstructor(),
forEachConstructorInitializer(
cxxCtorInitializer(
forField(unless(anyOf(getLangOpts().CPlusPlus20
@@ -222,18 +221,15 @@ void UseDefaultMemberInitCheck::registerMatchers(MatchFinder *Finder) {
: isBitField(),
hasInClassInitializer(anything()),
hasParent(recordDecl(isUnion()))))),
- isWritten(), withInitializer(ignoringImplicit(Init)))
+ withInitializer(Init))
.bind("default"))),
this);
Finder->addMatcher(
- cxxConstructorDecl(
- unless(ast_matchers::isTemplateInstantiation()),
- forEachConstructorInitializer(
- cxxCtorInitializer(forField(hasInClassInitializer(anything())),
- isWritten(),
- withInitializer(ignoringImplicit(Init)))
- .bind("existing"))),
+ cxxConstructorDecl(forEachConstructorInitializer(
+ cxxCtorInitializer(forField(hasInClassInitializer(anything())),
+ withInitializer(Init))
+ .bind("existing"))),
this);
}
diff --git a/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.h b/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.h
index fc26eb55c83a..1da57d8cd594 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.h
+++ b/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.h
@@ -30,6 +30,9 @@ class UseDefaultMemberInitCheck : public ClangTidyCheck {
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
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;
+ }
private:
void checkDefaultInit(const ast_matchers::MatchFinder::MatchResult &Result,
More information about the cfe-commits
mailing list