[clang-tools-extra] r329994 - [clang-tidy] [bugprone-parent-virtual-call] Minor cosmetic changes. NFC
Zinovy Nis via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 13 00:46:27 PDT 2018
Author: zinovy.nis
Date: Fri Apr 13 00:46:27 2018
New Revision: 329994
URL: http://llvm.org/viewvc/llvm-project?rev=329994&view=rev
Log:
[clang-tidy] [bugprone-parent-virtual-call] Minor cosmetic changes. NFC
Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
Modified: clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp?rev=329994&r1=329993&r2=329994&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp Fri Apr 13 00:46:27 2018
@@ -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 CXXRecordDe
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::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::registerMat
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);
More information about the cfe-commits
mailing list