diff options
Diffstat (limited to 'clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp')
| -rw-r--r-- | clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp index bd736743ae1..8146cb36cf2 100644 --- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp @@ -237,10 +237,26 @@ void IdentifierNamingCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher(namedDecl().bind("decl"), this); Finder->addMatcher(usingDecl().bind("using"), this); Finder->addMatcher(declRefExpr().bind("declRef"), this); - Finder->addMatcher(cxxConstructorDecl().bind("classRef"), this); - Finder->addMatcher(cxxDestructorDecl().bind("classRef"), this); + Finder->addMatcher(cxxConstructorDecl(unless(isImplicit())).bind("classRef"), + this); + Finder->addMatcher(cxxDestructorDecl(unless(isImplicit())).bind("classRef"), + this); Finder->addMatcher(typeLoc().bind("typeLoc"), this); Finder->addMatcher(nestedNameSpecifierLoc().bind("nestedNameLoc"), this); + Finder->addMatcher( + functionDecl(unless(cxxMethodDecl(isImplicit())), + hasBody(forEachDescendant(memberExpr().bind("memberExpr")))), + this); + Finder->addMatcher( + cxxConstructorDecl( + unless(isImplicit()), + forEachConstructorInitializer( + allOf(isWritten(), withInitializer(forEachDescendant( + memberExpr().bind("memberExpr")))))), + this); + Finder->addMatcher(fieldDecl(hasInClassInitializer( + forEachDescendant(memberExpr().bind("memberExpr")))), + this); } void IdentifierNamingCheck::registerPPCallbacks( @@ -710,8 +726,6 @@ static void addUsage(IdentifierNamingCheck::NamingCheckFailureMap &Failures, void IdentifierNamingCheck::check(const MatchFinder::MatchResult &Result) { if (const auto *Decl = Result.Nodes.getNodeAs<CXXConstructorDecl>("classRef")) { - if (Decl->isImplicit()) - return; addUsage(NamingCheckFailures, Decl->getParent(), Decl->getNameInfo().getSourceRange()); @@ -730,8 +744,6 @@ void IdentifierNamingCheck::check(const MatchFinder::MatchResult &Result) { if (const auto *Decl = Result.Nodes.getNodeAs<CXXDestructorDecl>("classRef")) { - if (Decl->isImplicit()) - return; SourceRange Range = Decl->getNameInfo().getSourceRange(); if (Range.getBegin().isInvalid()) @@ -806,6 +818,14 @@ void IdentifierNamingCheck::check(const MatchFinder::MatchResult &Result) { return; } + if (const auto *MemberRef = + Result.Nodes.getNodeAs<MemberExpr>("memberExpr")) { + SourceRange Range = MemberRef->getMemberNameInfo().getSourceRange(); + addUsage(NamingCheckFailures, MemberRef->getMemberDecl(), Range, + Result.SourceManager); + return; + } + if (const auto *Decl = Result.Nodes.getNodeAs<NamedDecl>("decl")) { if (!Decl->getIdentifier() || Decl->getName().empty() || Decl->isImplicit()) return; |

