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 @@ public: void storeOptions(ClangTidyOptions::OptionMap &Opts) override; void registerMatchers(ast_matchers::MatchFinder *Finder) override; void check(const ast_matchers::MatchFinder::MatchResult &Result) override; + llvm::Optional getCheckTraversalKind() const override { + return TK_IgnoreUnlessSpelledInSource; + } private: void checkDefaultInit(const ast_matchers::MatchFinder::MatchResult &Result,