diff options
author | Zinovy Nis <zinovy.nis@gmail.com> | 2018-04-13 07:46:27 +0000 |
---|---|---|
committer | Zinovy Nis <zinovy.nis@gmail.com> | 2018-04-13 07:46:27 +0000 |
commit | 94900f9a6f4a83464e7c279a864add43032b6393 (patch) | |
tree | 1cffcf7392bd88f070fb52643bf2c60ad62d1275 /clang-tidy/bugprone | |
parent | 9d3c220a397aae68832a1e71eb4d19be5228e649 (diff) |
[clang-tidy] [bugprone-parent-virtual-call] Minor cosmetic changes. NFC
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@329994 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-tidy/bugprone')
-rwxr-xr-x | clang-tidy/bugprone/ParentVirtualCallCheck.cpp | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/clang-tidy/bugprone/ParentVirtualCallCheck.cpp b/clang-tidy/bugprone/ParentVirtualCallCheck.cpp index a64564c0..7daf742d 100755 --- a/clang-tidy/bugprone/ParentVirtualCallCheck.cpp +++ b/clang-tidy/bugprone/ParentVirtualCallCheck.cpp @@ -11,6 +11,7 @@ #include "clang/AST/ASTContext.h" #include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/Tooling/FixIt.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" #include <algorithm> #include <cctype> @@ -27,13 +28,12 @@ static bool isParentOf(const CXXRecordDecl &Parent, const CXXRecordDecl &ThisClass) { if (Parent.getCanonicalDecl() == ThisClass.getCanonicalDecl()) return true; - for (const CXXBaseSpecifier &Base : ThisClass.bases()) { - auto *BaseDecl = Base.getType()->getAsCXXRecordDecl(); - assert(BaseDecl); - if (Parent.getCanonicalDecl() == BaseDecl->getCanonicalDecl()) - return true; - } - return false; + return ThisClass.bases_end() != + llvm::find_if(ThisClass.bases(), [=](const CXXBaseSpecifier &Base) { + auto *BaseDecl = Base.getType()->getAsCXXRecordDecl(); + assert(BaseDecl); + return Parent.getCanonicalDecl() == BaseDecl->getCanonicalDecl(); + }); } static BasesVector getParentsByGrandParent(const CXXRecordDecl &GrandParent, @@ -76,9 +76,9 @@ static std::string getExprAsString(const clang::Expr &E, clang::ASTContext &AC) { std::string Text = tooling::fixit::getText(E, AC).str(); Text.erase( - std::remove_if( - Text.begin(), Text.end(), - [](char c) { return std::isspace(static_cast<unsigned char>(c)); }), + llvm::remove_if( + Text, + [](char C) { return std::isspace(static_cast<unsigned char>(C)); }), Text.end()); return Text; } @@ -92,16 +92,11 @@ void ParentVirtualCallCheck::registerMatchers(MatchFinder *Finder) { hasSourceExpression(cxxThisExpr(hasType( type(anything()).bind("thisType"))))))) .bind("member")), - callee(cxxMethodDecl(isVirtual()))) - .bind("call"), + callee(cxxMethodDecl(isVirtual()))), this); } void ParentVirtualCallCheck::check(const MatchFinder::MatchResult &Result) { - const auto *MatchedDecl = Result.Nodes.getNodeAs<CXXMemberCallExpr>("call"); - (void)MatchedDecl; - assert(MatchedDecl); - const auto *Member = Result.Nodes.getNodeAs<MemberExpr>("member"); assert(Member); |