[clang-tools-extra] r247886 - Refactors AST matching code to use the new AST matcher names. This patch correlates to r247885 which performs the AST matcher rename in Clang.
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 17 06:31:26 PDT 2015
Author: aaronballman
Date: Thu Sep 17 08:31:25 2015
New Revision: 247886
URL: http://llvm.org/viewvc/llvm-project?rev=247886&view=rev
Log:
Refactors AST matching code to use the new AST matcher names. This patch correlates to r247885 which performs the AST matcher rename in Clang.
Modified:
clang-tools-extra/trunk/clang-modernize/AddOverride/AddOverrideMatchers.cpp
clang-tools-extra/trunk/clang-modernize/LoopConvert/LoopMatchers.cpp
clang-tools-extra/trunk/clang-modernize/PassByValue/PassByValueMatchers.cpp
clang-tools-extra/trunk/clang-modernize/ReplaceAutoPtr/ReplaceAutoPtrMatchers.cpp
clang-tools-extra/trunk/clang-modernize/UseAuto/UseAutoMatchers.cpp
clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp
clang-tools-extra/trunk/clang-tidy/google/OverloadedUnaryAndCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversionCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/SizeofContainerCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/UndelegatedConstructor.cpp
clang-tools-extra/trunk/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/UnusedRAIICheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/BracesAroundStatementsCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
Modified: clang-tools-extra/trunk/clang-modernize/AddOverride/AddOverrideMatchers.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-modernize/AddOverride/AddOverrideMatchers.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-modernize/AddOverride/AddOverrideMatchers.cpp (original)
+++ clang-tools-extra/trunk/clang-modernize/AddOverride/AddOverrideMatchers.cpp Thu Sep 17 08:31:25 2015
@@ -22,8 +22,8 @@ using namespace clang;
const char *MethodId = "method";
DeclarationMatcher makeCandidateForOverrideAttrMatcher() {
- return methodDecl(hasParent(recordDecl()),
+ return cxxMethodDecl(hasParent(recordDecl()),
isOverride(),
- unless(destructorDecl())).bind(MethodId);
+ unless(cxxDestructorDecl())).bind(MethodId);
}
Modified: clang-tools-extra/trunk/clang-modernize/LoopConvert/LoopMatchers.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-modernize/LoopConvert/LoopMatchers.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-modernize/LoopConvert/LoopMatchers.cpp (original)
+++ clang-tools-extra/trunk/clang-modernize/LoopConvert/LoopMatchers.cpp Thu Sep 17 08:31:25 2015
@@ -112,10 +112,10 @@ StatementMatcher makeArrayLoopMatcher()
/// - If the end iterator variable 'g' is defined, it is the same as 'f'
StatementMatcher makeIteratorLoopMatcher() {
StatementMatcher BeginCallMatcher =
- memberCallExpr(
+ cxxMemberCallExpr(
argumentCountIs(0),
callee(
- methodDecl(hasName("begin"))
+ cxxMethodDecl(hasName("begin"))
)
).bind(BeginCallName);
@@ -133,8 +133,8 @@ StatementMatcher makeIteratorLoopMatcher
DeclarationMatcher EndDeclMatcher =
varDecl(hasInitializer(anything())).bind(EndVarName);
- StatementMatcher EndCallMatcher =
- memberCallExpr(argumentCountIs(0), callee(methodDecl(hasName("end"))));
+ StatementMatcher EndCallMatcher = cxxMemberCallExpr(
+ argumentCountIs(0), callee(cxxMethodDecl(hasName("end"))));
StatementMatcher IteratorBoundMatcher =
expr(anyOf(ignoringParenImpCasts(declRefExpr(to(
@@ -148,7 +148,7 @@ StatementMatcher makeIteratorLoopMatcher
expr(ignoringParenImpCasts(declRefExpr(to(
varDecl().bind(ConditionVarName)))));
- StatementMatcher OverloadedNEQMatcher = operatorCallExpr(
+ StatementMatcher OverloadedNEQMatcher = cxxOperatorCallExpr(
hasOverloadedOperatorName("!="),
argumentCountIs(2),
hasArgument(0, IteratorComparisonMatcher),
@@ -159,7 +159,7 @@ StatementMatcher makeIteratorLoopMatcher
// reference then the return type is tagged with DerefByValueResultName.
internal::Matcher<VarDecl> TestDerefReturnsByValue =
hasType(
- recordDecl(
+ cxxRecordDecl(
hasMethod(
allOf(
hasOverloadedOperatorName("*"),
@@ -218,7 +218,7 @@ StatementMatcher makeIteratorLoopMatcher
))
)
),
- operatorCallExpr(
+ cxxOperatorCallExpr(
hasOverloadedOperatorName("++"),
hasArgument(0,
declRefExpr(to(
@@ -276,15 +276,15 @@ StatementMatcher makePseudoArrayLoopMatc
qualType(
isConstQualified(),
hasDeclaration(
- recordDecl(
+ cxxRecordDecl(
hasMethod(
- methodDecl(
+ cxxMethodDecl(
hasName("begin"),
isConst()
)
),
hasMethod(
- methodDecl(
+ cxxMethodDecl(
hasName("end"),
isConst()
)
@@ -295,7 +295,7 @@ StatementMatcher makePseudoArrayLoopMatc
qualType(
unless(isConstQualified()),
hasDeclaration(
- recordDecl(
+ cxxRecordDecl(
hasMethod(hasName("begin")),
hasMethod(hasName("end"))
)
@@ -304,12 +304,11 @@ StatementMatcher makePseudoArrayLoopMatc
)
);
- StatementMatcher SizeCallMatcher =
- memberCallExpr(argumentCountIs(0),
- callee(methodDecl(anyOf(hasName("size"),
- hasName("length")))),
- on(anyOf(hasType(pointsTo(RecordWithBeginEnd)),
- hasType(RecordWithBeginEnd))));
+ StatementMatcher SizeCallMatcher = cxxMemberCallExpr(
+ argumentCountIs(0),
+ callee(cxxMethodDecl(anyOf(hasName("size"), hasName("length")))),
+ on(anyOf(hasType(pointsTo(RecordWithBeginEnd)),
+ hasType(RecordWithBeginEnd))));
StatementMatcher EndInitMatcher =
expr(anyOf(
Modified: clang-tools-extra/trunk/clang-modernize/PassByValue/PassByValueMatchers.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-modernize/PassByValue/PassByValueMatchers.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-modernize/PassByValue/PassByValueMatchers.cpp (original)
+++ clang-tools-extra/trunk/clang-modernize/PassByValue/PassByValueMatchers.cpp Thu Sep 17 08:31:25 2015
@@ -59,13 +59,13 @@ static TypeMatcher nonConstValueType() {
}
DeclarationMatcher makePassByValueCtorParamMatcher() {
- return constructorDecl(
- forEachConstructorInitializer(ctorInitializer(
+ return cxxConstructorDecl(
+ forEachConstructorInitializer(cxxCtorInitializer(
// Clang builds a CXXConstructExpr only when it knowns which
// constructor will be called. In dependent contexts a ParenListExpr
// is generated instead of a CXXConstructExpr, filtering out templates
// automatically for us.
- withInitializer(constructExpr(
+ withInitializer(cxxConstructExpr(
has(declRefExpr(to(
parmVarDecl(hasType(qualType(
// match only const-ref or a non-const value
@@ -73,9 +73,9 @@ DeclarationMatcher makePassByValueCtorPa
// shouldn't be modified.
anyOf(constRefType(), nonConstValueType()))))
.bind(PassByValueParamId)))),
- hasDeclaration(constructorDecl(
+ hasDeclaration(cxxConstructorDecl(
isCopyConstructor(), unless(isDeleted()),
- hasDeclContext(recordDecl(isMoveConstructible())))))))
+ hasDeclContext(cxxRecordDecl(isMoveConstructible())))))))
.bind(PassByValueInitializerId)))
.bind(PassByValueCtorId);
}
Modified: clang-tools-extra/trunk/clang-modernize/ReplaceAutoPtr/ReplaceAutoPtrMatchers.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-modernize/ReplaceAutoPtr/ReplaceAutoPtrMatchers.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-modernize/ReplaceAutoPtr/ReplaceAutoPtrMatchers.cpp (original)
+++ clang-tools-extra/trunk/clang-modernize/ReplaceAutoPtr/ReplaceAutoPtrMatchers.cpp Thu Sep 17 08:31:25 2015
@@ -67,13 +67,13 @@ DeclarationMatcher makeAutoPtrUsingDeclM
StatementMatcher makeTransferOwnershipExprMatcher() {
StatementMatcher assignOperator =
- operatorCallExpr(allOf(
+ cxxOperatorCallExpr(allOf(
hasOverloadedOperatorName("="),
- callee(methodDecl(ofClass(AutoPtrDecl))),
+ callee(cxxMethodDecl(ofClass(AutoPtrDecl))),
hasArgument(1, MovableArgumentMatcher)));
StatementMatcher copyCtor =
- constructExpr(allOf(hasType(AutoPtrType),
+ cxxConstructExpr(allOf(hasType(AutoPtrType),
argumentCountIs(1),
hasArgument(0, MovableArgumentMatcher)));
Modified: clang-tools-extra/trunk/clang-modernize/UseAuto/UseAutoMatchers.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-modernize/UseAuto/UseAutoMatchers.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-modernize/UseAuto/UseAutoMatchers.cpp (original)
+++ clang-tools-extra/trunk/clang-modernize/UseAuto/UseAutoMatchers.cpp Thu Sep 17 08:31:25 2015
@@ -258,7 +258,7 @@ StatementMatcher makeDeclWithNewMatcher(
unless(has(varDecl(
anyOf(
unless(hasInitializer(
- ignoringParenImpCasts(newExpr())
+ ignoringParenImpCasts(cxxNewExpr())
)),
// FIXME: TypeLoc information is not reliable where CV qualifiers are
// concerned so these types can't be handled for now.
Modified: clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp Thu Sep 17 08:31:25 2015
@@ -23,8 +23,8 @@ void ExplicitConstructorCheck::registerM
// Only register the matchers for C++; the functionality currently does not
// provide any benefit to other languages, despite being benign.
if (getLangOpts().CPlusPlus)
- Finder->addMatcher(constructorDecl(unless(isInstantiated())).bind("ctor"),
- this);
+ Finder->addMatcher(
+ cxxConstructorDecl(unless(isInstantiated())).bind("ctor"), this);
}
// Looks for the token matching the predicate and returns the range of the found
Modified: clang-tools-extra/trunk/clang-tidy/google/OverloadedUnaryAndCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/OverloadedUnaryAndCheck.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/OverloadedUnaryAndCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/google/OverloadedUnaryAndCheck.cpp Thu Sep 17 08:31:25 2015
@@ -27,14 +27,15 @@ OverloadedUnaryAndCheck::registerMatcher
return;
// Match unary methods that overload operator&.
- Finder->addMatcher(methodDecl(parameterCountIs(0), hasOverloadedOperatorName(
- "&")).bind("overload"),
- this);
+ Finder->addMatcher(
+ cxxMethodDecl(parameterCountIs(0), hasOverloadedOperatorName("&"))
+ .bind("overload"),
+ this);
// Also match freestanding unary operator& overloads. Be careful not to match
// binary methods.
Finder->addMatcher(
functionDecl(
- allOf(unless(methodDecl()),
+ allOf(unless(cxxMethodDecl()),
functionDecl(parameterCountIs(1),
hasOverloadedOperatorName("&")).bind("overload"))),
this);
Modified: clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp Thu Sep 17 08:31:25 2015
@@ -26,7 +26,7 @@ ArgumentCommentCheck::ArgumentCommentChe
void ArgumentCommentCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(
- callExpr(unless(operatorCallExpr()),
+ callExpr(unless(cxxOperatorCallExpr()),
// NewCallback's arguments relate to the pointed function, don't
// check them against NewCallback's parameter names.
// FIXME: Make this configurable.
@@ -34,7 +34,7 @@ void ArgumentCommentCheck::registerMatch
hasName("NewCallback"), hasName("NewPermanentCallback"))))))
.bind("expr"),
this);
- Finder->addMatcher(constructExpr().bind("expr"), this);
+ Finder->addMatcher(cxxConstructExpr().bind("expr"), this);
}
std::vector<std::pair<SourceLocation, StringRef>>
Modified: clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp Thu Sep 17 08:31:25 2015
@@ -24,20 +24,21 @@ void AssignOperatorSignatureCheck::regis
if (!getLangOpts().CPlusPlus)
return;
- const auto HasGoodReturnType = methodDecl(returns(lValueReferenceType(pointee(
- unless(isConstQualified()), hasDeclaration(equalsBoundNode("class"))))));
+ const auto HasGoodReturnType = cxxMethodDecl(returns(
+ lValueReferenceType(pointee(unless(isConstQualified()),
+ hasDeclaration(equalsBoundNode("class"))))));
const auto IsSelf = qualType(
anyOf(hasDeclaration(equalsBoundNode("class")),
referenceType(pointee(hasDeclaration(equalsBoundNode("class"))))));
const auto IsSelfAssign =
- methodDecl(unless(anyOf(isDeleted(), isPrivate(), isImplicit())),
- hasName("operator="), ofClass(recordDecl().bind("class")),
- hasParameter(0, parmVarDecl(hasType(IsSelf))))
+ cxxMethodDecl(unless(anyOf(isDeleted(), isPrivate(), isImplicit())),
+ hasName("operator="), ofClass(recordDecl().bind("class")),
+ hasParameter(0, parmVarDecl(hasType(IsSelf))))
.bind("method");
Finder->addMatcher(
- methodDecl(IsSelfAssign, unless(HasGoodReturnType)).bind("ReturnType"),
+ cxxMethodDecl(IsSelfAssign, unless(HasGoodReturnType)).bind("ReturnType"),
this);
const auto BadSelf = referenceType(
@@ -45,11 +46,13 @@ void AssignOperatorSignatureCheck::regis
rValueReferenceType(pointee(isConstQualified()))));
Finder->addMatcher(
- methodDecl(IsSelfAssign, hasParameter(0, parmVarDecl(hasType(BadSelf))))
+ cxxMethodDecl(IsSelfAssign,
+ hasParameter(0, parmVarDecl(hasType(BadSelf))))
.bind("ArgumentType"),
this);
- Finder->addMatcher(methodDecl(IsSelfAssign, isConst()).bind("Const"), this);
+ Finder->addMatcher(cxxMethodDecl(IsSelfAssign, isConst()).bind("Const"),
+ this);
}
Modified: clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversionCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversionCheck.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversionCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversionCheck.cpp Thu Sep 17 08:31:25 2015
@@ -63,7 +63,7 @@ void BoolPointerImplicitConversionCheck:
// bool.
!match(findAll(callExpr(hasAnyArgument(DeclRef))), *If, *Result.Context)
.empty() ||
- !match(findAll(deleteExpr(has(expr(DeclRef)))), *If, *Result.Context)
+ !match(findAll(cxxDeleteExpr(has(expr(DeclRef)))), *If, *Result.Context)
.empty())
return;
Modified: clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp Thu Sep 17 08:31:25 2015
@@ -25,15 +25,15 @@ void InaccurateEraseCheck::registerMatch
return;
const auto CheckForEndCall = hasArgument(
- 1,
- anyOf(constructExpr(has(memberCallExpr(callee(methodDecl(hasName("end"))))
- .bind("InaccEndCall"))),
- anything()));
+ 1, anyOf(cxxConstructExpr(
+ has(cxxMemberCallExpr(callee(cxxMethodDecl(hasName("end"))))
+ .bind("InaccEndCall"))),
+ anything()));
Finder->addMatcher(
- memberCallExpr(
+ cxxMemberCallExpr(
on(hasType(namedDecl(matchesName("^::std::")))),
- callee(methodDecl(hasName("erase"))), argumentCountIs(1),
+ callee(cxxMethodDecl(hasName("erase"))), argumentCountIs(1),
hasArgument(0, has(callExpr(callee(functionDecl(matchesName(
"^::std::(remove(_if)?|unique)$"))),
CheckForEndCall)
Modified: clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp Thu Sep 17 08:31:25 2015
@@ -41,16 +41,16 @@ void InefficientAlgorithmCheck::register
callExpr(
callee(functionDecl(matchesName(Algorithms))),
hasArgument(
- 0, constructExpr(has(memberCallExpr(
- callee(methodDecl(hasName("begin"))),
+ 0, cxxConstructExpr(has(cxxMemberCallExpr(
+ callee(cxxMethodDecl(hasName("begin"))),
on(declRefExpr(
hasDeclaration(decl().bind("IneffContObj")),
anyOf(hasType(ContainerMatcher.bind("IneffCont")),
hasType(pointsTo(
ContainerMatcher.bind("IneffContPtr")))))
.bind("IneffContExpr")))))),
- hasArgument(1, constructExpr(has(memberCallExpr(
- callee(methodDecl(hasName("end"))),
+ hasArgument(1, cxxConstructExpr(has(cxxMemberCallExpr(
+ callee(cxxMethodDecl(hasName("end"))),
on(declRefExpr(hasDeclaration(
equalsBoundNode("IneffContObj")))))))),
hasArgument(2, expr().bind("AlgParam")),
Modified: clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp Thu Sep 17 08:31:25 2015
@@ -23,14 +23,16 @@ void MoveConstructorInitCheck::registerM
return;
Finder->addMatcher(
- constructorDecl(unless(isImplicit()), allOf(
- isMoveConstructor(),
- hasAnyConstructorInitializer(
- ctorInitializer(withInitializer(constructExpr(hasDeclaration(
- constructorDecl(isCopyConstructor()).bind("ctor")
- )))).bind("init")
- )
- )), this);
+ cxxConstructorDecl(
+ unless(isImplicit()),
+ allOf(isMoveConstructor(),
+ hasAnyConstructorInitializer(
+ cxxCtorInitializer(
+ withInitializer(cxxConstructExpr(hasDeclaration(
+ cxxConstructorDecl(isCopyConstructor())
+ .bind("ctor")))))
+ .bind("init")))),
+ this);
}
void MoveConstructorInitCheck::check(const MatchFinder::MatchResult &Result) {
Modified: clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp Thu Sep 17 08:31:25 2015
@@ -23,8 +23,8 @@ void NoexceptMoveConstructorCheck::regis
return;
Finder->addMatcher(
- methodDecl(anyOf(constructorDecl(), hasOverloadedOperatorName("=")),
- unless(isImplicit()), unless(isDeleted()))
+ cxxMethodDecl(anyOf(cxxConstructorDecl(), hasOverloadedOperatorName("=")),
+ unless(isImplicit()), unless(isDeleted()))
.bind("decl"),
this);
}
Modified: clang-tools-extra/trunk/clang-tidy/misc/SizeofContainerCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/SizeofContainerCheck.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/SizeofContainerCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/SizeofContainerCheck.cpp Thu Sep 17 08:31:25 2015
@@ -19,11 +19,12 @@ namespace tidy {
void SizeofContainerCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(
expr(unless(isInTemplateInstantiation()),
- expr(sizeOfExpr(has(expr(hasType(hasCanonicalType(hasDeclaration(
- recordDecl(matchesName("^(::std::|::string)"),
- unless(matchesName("^::std::(bitset|array)$")),
- hasMethod(methodDecl(hasName("size"), isPublic(),
- isConst()))))))))))
+ expr(sizeOfExpr(has(
+ expr(hasType(hasCanonicalType(hasDeclaration(cxxRecordDecl(
+ matchesName("^(::std::|::string)"),
+ unless(matchesName("^::std::(bitset|array)$")),
+ hasMethod(cxxMethodDecl(hasName("size"), isPublic(),
+ isConst()))))))))))
.bind("sizeof"),
// Ignore ARRAYSIZE(<array of containers>) pattern.
unless(hasAncestor(binaryOperator(
Modified: clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp Thu Sep 17 08:31:25 2015
@@ -33,8 +33,8 @@ void StaticAssertCheck::registerMatchers
return;
auto IsAlwaysFalse = expr(ignoringParenImpCasts(
- expr(anyOf(boolLiteral(equals(false)), integerLiteral(equals(0)),
- nullPtrLiteralExpr(), gnuNullExpr()))
+ expr(anyOf(cxxBoolLiteral(equals(false)), integerLiteral(equals(0)),
+ cxxNullPtrLiteralExpr(), gnuNullExpr()))
.bind("isAlwaysFalse")));
auto IsAlwaysFalseWithCast = ignoringParenImpCasts(anyOf(
IsAlwaysFalse, cStyleCastExpr(has(IsAlwaysFalse)).bind("castExpr")));
Modified: clang-tools-extra/trunk/clang-tidy/misc/UndelegatedConstructor.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UndelegatedConstructor.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/UndelegatedConstructor.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UndelegatedConstructor.cpp Thu Sep 17 08:31:25 2015
@@ -63,10 +63,11 @@ void UndelegatedConstructorCheck::regist
Finder->addMatcher(
compoundStmt(
- hasParent(constructorDecl(ofClass(recordDecl().bind("parent")))),
+ hasParent(
+ cxxConstructorDecl(ofClass(cxxRecordDecl().bind("parent")))),
forEach(ignoringTemporaryExpr(
- constructExpr(hasDeclaration(constructorDecl(ofClass(
- recordDecl(baseOfBoundNode("parent"))))))
+ cxxConstructExpr(hasDeclaration(cxxConstructorDecl(ofClass(
+ cxxRecordDecl(baseOfBoundNode("parent"))))))
.bind("construct"))),
unless(isInTemplateInstantiation())),
this);
Modified: clang-tools-extra/trunk/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp Thu Sep 17 08:31:25 2015
@@ -24,18 +24,19 @@ void UniqueptrResetReleaseCheck::registe
return;
Finder->addMatcher(
- memberCallExpr(
+ cxxMemberCallExpr(
on(expr().bind("left")), callee(memberExpr().bind("reset_member")),
- callee(methodDecl(hasName("reset"),
- ofClass(recordDecl(hasName("::std::unique_ptr"),
- decl().bind("left_class"))))),
- has(memberCallExpr(
+ callee(
+ cxxMethodDecl(hasName("reset"),
+ ofClass(cxxRecordDecl(hasName("::std::unique_ptr"),
+ decl().bind("left_class"))))),
+ has(cxxMemberCallExpr(
on(expr().bind("right")),
callee(memberExpr().bind("release_member")),
- callee(methodDecl(
+ callee(cxxMethodDecl(
hasName("release"),
- ofClass(recordDecl(hasName("::std::unique_ptr"),
- decl().bind("right_class"))))))))
+ ofClass(cxxRecordDecl(hasName("::std::unique_ptr"),
+ decl().bind("right_class"))))))))
.bind("reset_call"),
this);
}
Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedRAIICheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedRAIICheck.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedRAIICheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedRAIICheck.cpp Thu Sep 17 08:31:25 2015
@@ -33,13 +33,13 @@ void UnusedRAIICheck::registerMatchers(M
// Look for temporaries that are constructed in-place and immediately
// destroyed. Look for temporaries created by a functional cast but not for
// those returned from a call.
- auto BindTemp = bindTemporaryExpr(unless(has(callExpr()))).bind("temp");
+ auto BindTemp = cxxBindTemporaryExpr(unless(has(callExpr()))).bind("temp");
Finder->addMatcher(
exprWithCleanups(
unless(isInTemplateInstantiation()),
hasParent(compoundStmt().bind("compound")),
- hasType(recordDecl(hasNonTrivialDestructor())),
- anyOf(has(BindTemp), has(functionalCastExpr(has(BindTemp)))))
+ hasType(cxxRecordDecl(hasNonTrivialDestructor())),
+ anyOf(has(BindTemp), has(cxxFunctionalCastExpr(has(BindTemp)))))
.bind("expr"),
this);
}
Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp Thu Sep 17 08:31:25 2015
@@ -112,7 +112,8 @@ StatementMatcher makeArrayLoopMatcher()
/// - If the end iterator variable 'g' is defined, it is the same as 'f'.
StatementMatcher makeIteratorLoopMatcher() {
StatementMatcher BeginCallMatcher =
- memberCallExpr(argumentCountIs(0), callee(methodDecl(hasName("begin"))))
+ cxxMemberCallExpr(argumentCountIs(0),
+ callee(cxxMethodDecl(hasName("begin"))))
.bind(BeginCallName);
DeclarationMatcher InitDeclMatcher =
@@ -125,8 +126,8 @@ StatementMatcher makeIteratorLoopMatcher
DeclarationMatcher EndDeclMatcher =
varDecl(hasInitializer(anything())).bind(EndVarName);
- StatementMatcher EndCallMatcher =
- memberCallExpr(argumentCountIs(0), callee(methodDecl(hasName("end"))));
+ StatementMatcher EndCallMatcher = cxxMemberCallExpr(
+ argumentCountIs(0), callee(cxxMethodDecl(hasName("end"))));
StatementMatcher IteratorBoundMatcher =
expr(anyOf(ignoringParenImpCasts(
@@ -139,15 +140,15 @@ StatementMatcher makeIteratorLoopMatcher
ignoringParenImpCasts(declRefExpr(to(varDecl().bind(ConditionVarName)))));
StatementMatcher OverloadedNEQMatcher =
- operatorCallExpr(hasOverloadedOperatorName("!="), argumentCountIs(2),
- hasArgument(0, IteratorComparisonMatcher),
- hasArgument(1, IteratorBoundMatcher));
+ cxxOperatorCallExpr(hasOverloadedOperatorName("!="), argumentCountIs(2),
+ hasArgument(0, IteratorComparisonMatcher),
+ hasArgument(1, IteratorBoundMatcher));
// This matcher tests that a declaration is a CXXRecordDecl that has an
// overloaded operator*(). If the operator*() returns by value instead of by
// reference then the return type is tagged with DerefByValueResultName.
internal::Matcher<VarDecl> TestDerefReturnsByValue =
- hasType(recordDecl(hasMethod(allOf(
+ hasType(cxxRecordDecl(hasMethod(allOf(
hasOverloadedOperatorName("*"),
anyOf(
// Tag the return type if it's by value.
@@ -178,7 +179,7 @@ StatementMatcher makeIteratorLoopMatcher
hasUnaryOperand(declRefExpr(
to(varDecl(hasType(pointsTo(AnyType)))
.bind(IncrementVarName))))),
- operatorCallExpr(
+ cxxOperatorCallExpr(
hasOverloadedOperatorName("++"),
hasArgument(
0, declRefExpr(to(varDecl(TestDerefReturnsByValue)
@@ -229,20 +230,20 @@ StatementMatcher makePseudoArrayLoopMatc
// are also allowed.
TypeMatcher RecordWithBeginEnd = qualType(
anyOf(qualType(isConstQualified(),
- hasDeclaration(recordDecl(
- hasMethod(methodDecl(hasName("begin"), isConst())),
- hasMethod(methodDecl(hasName("end"),
- isConst())))) // hasDeclaration
- ), // qualType
+ hasDeclaration(cxxRecordDecl(
+ hasMethod(cxxMethodDecl(hasName("begin"), isConst())),
+ hasMethod(cxxMethodDecl(hasName("end"),
+ isConst())))) // hasDeclaration
+ ), // qualType
qualType(unless(isConstQualified()),
hasDeclaration(
- recordDecl(hasMethod(hasName("begin")),
- hasMethod(hasName("end"))))) // qualType
+ cxxRecordDecl(hasMethod(hasName("begin")),
+ hasMethod(hasName("end"))))) // qualType
));
- StatementMatcher SizeCallMatcher = memberCallExpr(
+ StatementMatcher SizeCallMatcher = cxxMemberCallExpr(
argumentCountIs(0),
- callee(methodDecl(anyOf(hasName("size"), hasName("length")))),
+ callee(cxxMethodDecl(anyOf(hasName("size"), hasName("length")))),
on(anyOf(hasType(pointsTo(RecordWithBeginEnd)),
hasType(RecordWithBeginEnd))));
Modified: clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp Thu Sep 17 08:31:25 2015
@@ -131,14 +131,14 @@ void PassByValueCheck::registerMatchers(
// provide any benefit to other languages, despite being benign.
if (getLangOpts().CPlusPlus) {
Finder->addMatcher(
- constructorDecl(
+ cxxConstructorDecl(
forEachConstructorInitializer(
- ctorInitializer(
+ cxxCtorInitializer(
// Clang builds a CXXConstructExpr only whin it knows which
// constructor will be called. In dependent contexts a
// ParenListExpr is generated instead of a CXXConstructExpr,
// filtering out templates automatically for us.
- withInitializer(constructExpr(
+ withInitializer(cxxConstructExpr(
has(declRefExpr(to(
parmVarDecl(
hasType(qualType(
@@ -148,10 +148,10 @@ void PassByValueCheck::registerMatchers(
anyOf(constRefType(),
nonConstValueType()))))
.bind("Param")))),
- hasDeclaration(constructorDecl(
+ hasDeclaration(cxxConstructorDecl(
isCopyConstructor(), unless(isDeleted()),
hasDeclContext(
- recordDecl(isMoveConstructible())))))))
+ cxxRecordDecl(isMoveConstructible())))))))
.bind("Initializer")))
.bind("Ctor"),
this);
Modified: clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp Thu Sep 17 08:31:25 2015
@@ -130,11 +130,12 @@ DeclarationMatcher makeAutoPtrUsingDeclM
/// ~~~~^
/// \endcode
StatementMatcher makeTransferOwnershipExprMatcher() {
- return anyOf(operatorCallExpr(allOf(hasOverloadedOperatorName("="),
- callee(methodDecl(ofClass(AutoPtrDecl))),
- hasArgument(1, MovableArgumentMatcher))),
- constructExpr(allOf(hasType(AutoPtrType), argumentCountIs(1),
- hasArgument(0, MovableArgumentMatcher))));
+ return anyOf(
+ cxxOperatorCallExpr(allOf(hasOverloadedOperatorName("="),
+ callee(cxxMethodDecl(ofClass(AutoPtrDecl))),
+ hasArgument(1, MovableArgumentMatcher))),
+ cxxConstructExpr(allOf(hasType(AutoPtrType), argumentCountIs(1),
+ hasArgument(0, MovableArgumentMatcher))));
}
/// \brief Locates the \c auto_ptr token when it is referred by a \c TypeLoc.
Modified: clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.cpp Thu Sep 17 08:31:25 2015
@@ -42,7 +42,7 @@ void ShrinkToFitCheck::registerMatchers(
memberExpr(member(valueDecl().bind("ContainerDecl")));
const auto ShrinkableAsDecl =
declRefExpr(hasDeclaration(valueDecl().bind("ContainerDecl")));
- const auto CopyCtorCall = constructExpr(
+ const auto CopyCtorCall = cxxConstructExpr(
hasArgument(0, anyOf(ShrinkableAsMember, ShrinkableAsDecl,
unaryOperator(has(ShrinkableAsMember)),
unaryOperator(has(ShrinkableAsDecl)))));
@@ -54,11 +54,11 @@ void ShrinkToFitCheck::registerMatchers(
has(declRefExpr(hasDeclaration(equalsBoundNode("ContainerDecl")))))));
Finder->addMatcher(
- memberCallExpr(on(hasType(namedDecl(stlShrinkableContainer()))),
- callee(methodDecl(hasName("swap"))),
- has(memberExpr(hasDescendant(CopyCtorCall))),
- hasArgument(0, SwapParam.bind("ContainerToShrink")),
- unless(isInTemplateInstantiation()))
+ cxxMemberCallExpr(on(hasType(namedDecl(stlShrinkableContainer()))),
+ callee(cxxMethodDecl(hasName("swap"))),
+ has(memberExpr(hasDescendant(CopyCtorCall))),
+ hasArgument(0, SwapParam.bind("ContainerToShrink")),
+ unless(isInTemplateInstantiation()))
.bind("CopyAndSwapTrick"),
this);
}
Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp Thu Sep 17 08:31:25 2015
@@ -218,20 +218,21 @@ StatementMatcher makeIteratorDeclMatcher
}
StatementMatcher makeDeclWithNewMatcher() {
- return declStmt(has(varDecl()),
- unless(has(varDecl(anyOf(
- unless(hasInitializer(ignoringParenImpCasts(newExpr()))),
- // FIXME: TypeLoc information is not reliable where CV
- // qualifiers are concerned so these types can't be
- // handled for now.
- hasType(pointerType(
- pointee(hasCanonicalType(hasLocalQualifiers())))),
+ return declStmt(
+ has(varDecl()),
+ unless(has(varDecl(anyOf(
+ unless(hasInitializer(ignoringParenImpCasts(cxxNewExpr()))),
+ // FIXME: TypeLoc information is not reliable where CV
+ // qualifiers are concerned so these types can't be
+ // handled for now.
+ hasType(pointerType(
+ pointee(hasCanonicalType(hasLocalQualifiers())))),
- // FIXME: Handle function pointers. For now we ignore them
- // because the replacement replaces the entire type
- // specifier source range which includes the identifier.
- hasType(pointsTo(
- pointsTo(parenType(innerType(functionType()))))))))))
+ // FIXME: Handle function pointers. For now we ignore them
+ // because the replacement replaces the entire type
+ // specifier source range which includes the identifier.
+ hasType(pointsTo(
+ pointsTo(parenType(innerType(functionType()))))))))))
.bind(DeclWithNewId);
}
Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp Thu Sep 17 08:31:25 2015
@@ -21,7 +21,7 @@ namespace modernize {
void UseOverrideCheck::registerMatchers(MatchFinder *Finder) {
// Only register the matcher for C++11.
if (getLangOpts().CPlusPlus11)
- Finder->addMatcher(methodDecl(isOverride()).bind("method"), this);
+ Finder->addMatcher(cxxMethodDecl(isOverride()).bind("method"), this);
}
// Re-lex the tokens to get precise locations to insert 'override' and remove
Modified: clang-tools-extra/trunk/clang-tidy/readability/BracesAroundStatementsCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/BracesAroundStatementsCheck.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/readability/BracesAroundStatementsCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/readability/BracesAroundStatementsCheck.cpp Thu Sep 17 08:31:25 2015
@@ -127,7 +127,7 @@ void BracesAroundStatementsCheck::regist
Finder->addMatcher(whileStmt().bind("while"), this);
Finder->addMatcher(doStmt().bind("do"), this);
Finder->addMatcher(forStmt().bind("for"), this);
- Finder->addMatcher(forRangeStmt().bind("for-range"), this);
+ Finder->addMatcher(cxxForRangeStmt().bind("for-range"), this);
}
void
Modified: clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp Thu Sep 17 08:31:25 2015
@@ -75,12 +75,13 @@ void ContainerSizeEmptyCheck::registerMa
hasParent(explicitCastExpr(hasDestinationType(isBoolType()))));
Finder->addMatcher(
- memberCallExpr(
+ cxxMemberCallExpr(
on(expr(anyOf(hasType(namedDecl(stlContainer())),
hasType(pointsTo(namedDecl(stlContainer()))),
hasType(references(namedDecl(stlContainer())))))
.bind("STLObject")),
- callee(methodDecl(hasName("size"))), WrongUse).bind("SizeCallExpr"),
+ callee(cxxMethodDecl(hasName("size"))), WrongUse)
+ .bind("SizeCallExpr"),
this);
}
Modified: clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp Thu Sep 17 08:31:25 2015
@@ -36,7 +36,7 @@ void FunctionSizeCheck::registerMatchers
stmt(unless(compoundStmt()),
hasParent(stmt(anyOf(compoundStmt(), ifStmt(),
anyOf(whileStmt(), doStmt(),
- forRangeStmt(), forStmt())))))
+ cxxForRangeStmt(), forStmt())))))
.bind("stmt"))).bind("func"),
this);
}
Modified: clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp Thu Sep 17 08:31:25 2015
@@ -19,24 +19,26 @@ namespace readability {
namespace {
internal::Matcher<Expr> callToGet(internal::Matcher<Decl> OnClass) {
- return memberCallExpr(
+ return cxxMemberCallExpr(
on(expr(anyOf(hasType(OnClass),
- hasType(qualType(pointsTo(decl(OnClass).bind(
- "ptr_to_ptr")))))).bind("smart_pointer")),
- unless(callee(memberExpr(hasObjectExpression(thisExpr())))),
- callee(methodDecl(hasName("get")))).bind("redundant_get");
+ hasType(qualType(
+ pointsTo(decl(OnClass).bind("ptr_to_ptr"))))))
+ .bind("smart_pointer")),
+ unless(callee(memberExpr(hasObjectExpression(cxxThisExpr())))),
+ callee(cxxMethodDecl(hasName("get"))))
+ .bind("redundant_get");
}
void registerMatchersForGetArrowStart(MatchFinder *Finder,
MatchFinder::MatchCallback *Callback) {
const auto QuacksLikeASmartptr = recordDecl(
recordDecl().bind("duck_typing"),
- has(methodDecl(hasName("operator->"),
- returns(qualType(pointsTo(type().bind("op->Type")))))),
- has(methodDecl(hasName("operator*"),
- returns(qualType(references(type().bind("op*Type")))))),
- has(methodDecl(hasName("get"),
- returns(qualType(pointsTo(type().bind("getType")))))));
+ has(cxxMethodDecl(hasName("operator->"),
+ returns(qualType(pointsTo(type().bind("op->Type")))))),
+ has(cxxMethodDecl(hasName("operator*"),
+ returns(qualType(references(type().bind("op*Type")))))),
+ has(cxxMethodDecl(hasName("get"),
+ returns(qualType(pointsTo(type().bind("getType")))))));
// Catch 'ptr.get()->Foo()'
Finder->addMatcher(memberExpr(expr().bind("memberExpr"), isArrow(),
@@ -63,9 +65,10 @@ void registerMatchersForGetEquals(MatchF
// Matches against nullptr.
Finder->addMatcher(
- binaryOperator(anyOf(hasOperatorName("=="), hasOperatorName("!=")),
- hasEitherOperand(ignoringImpCasts(nullPtrLiteralExpr())),
- hasEitherOperand(callToGet(IsAKnownSmartptr))),
+ binaryOperator(
+ anyOf(hasOperatorName("=="), hasOperatorName("!=")),
+ hasEitherOperand(ignoringImpCasts(cxxNullPtrLiteralExpr())),
+ hasEitherOperand(callToGet(IsAKnownSmartptr))),
Callback);
// TODO: Catch ptr.get() == other_ptr.get()
}
Modified: clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp Thu Sep 17 08:31:25 2015
@@ -86,40 +86,42 @@ void RedundantStringCStrCheck::registerM
return;
Finder->addMatcher(
- constructExpr(
- hasDeclaration(methodDecl(hasName(StringConstructor))),
+ cxxConstructExpr(
+ hasDeclaration(cxxMethodDecl(hasName(StringConstructor))),
argumentCountIs(2),
// The first argument must have the form x.c_str() or p->c_str()
// where the method is string::c_str(). We can use the copy
// constructor of string instead (or the compiler might share
// the string object).
- hasArgument(
- 0, memberCallExpr(callee(memberExpr().bind("member")),
- callee(methodDecl(hasName(StringCStrMethod))),
- on(expr().bind("arg"))).bind("call")),
+ hasArgument(0, cxxMemberCallExpr(
+ callee(memberExpr().bind("member")),
+ callee(cxxMethodDecl(hasName(StringCStrMethod))),
+ on(expr().bind("arg")))
+ .bind("call")),
// The second argument is the alloc object which must not be
// present explicitly.
- hasArgument(1, defaultArgExpr())),
+ hasArgument(1, cxxDefaultArgExpr())),
this);
Finder->addMatcher(
- constructExpr(
+ cxxConstructExpr(
// Implicit constructors of these classes are overloaded
// wrt. string types and they internally make a StringRef
// referring to the argument. Passing a string directly to
// them is preferred to passing a char pointer.
hasDeclaration(
- methodDecl(anyOf(hasName("::llvm::StringRef::StringRef"),
- hasName("::llvm::Twine::Twine")))),
+ cxxMethodDecl(anyOf(hasName("::llvm::StringRef::StringRef"),
+ hasName("::llvm::Twine::Twine")))),
argumentCountIs(1),
// The only argument must have the form x.c_str() or p->c_str()
// where the method is string::c_str(). StringRef also has
// a constructor from string which is more efficient (avoids
// strlen), so we can construct StringRef from the string
// directly.
- hasArgument(
- 0, memberCallExpr(callee(memberExpr().bind("member")),
- callee(methodDecl(hasName(StringCStrMethod))),
- on(expr().bind("arg"))).bind("call"))),
+ hasArgument(0, cxxMemberCallExpr(
+ callee(memberExpr().bind("member")),
+ callee(cxxMethodDecl(hasName(StringCStrMethod))),
+ on(expr().bind("arg")))
+ .bind("call"))),
this);
}
Modified: clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp?rev=247886&r1=247885&r2=247886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp Thu Sep 17 08:31:25 2015
@@ -75,7 +75,8 @@ const CXXBoolLiteralExpr *getBoolLiteral
internal::Matcher<Stmt> returnsBool(bool Value, StringRef Id = "ignored") {
auto SimpleReturnsBool =
- returnStmt(has(boolLiteral(equals(Value)).bind(Id))).bind("returns-bool");
+ returnStmt(has(cxxBoolLiteral(equals(Value)).bind(Id)))
+ .bind("returns-bool");
return anyOf(SimpleReturnsBool,
compoundStmt(statementCountIs(1), has(SimpleReturnsBool)));
}
@@ -268,11 +269,12 @@ void SimplifyBooleanExprCheck::matchBool
StringRef OperatorName,
StringRef BooleanId) {
Finder->addMatcher(
- binaryOperator(isExpansionInMainFile(), hasOperatorName(OperatorName),
- hasLHS(allOf(expr().bind(LHSId),
- boolLiteral(equals(Value)).bind(BooleanId))),
- hasRHS(expr().bind(RHSId)),
- unless(hasRHS(hasDescendant(boolLiteral())))),
+ binaryOperator(
+ isExpansionInMainFile(), hasOperatorName(OperatorName),
+ hasLHS(allOf(expr().bind(LHSId),
+ cxxBoolLiteral(equals(Value)).bind(BooleanId))),
+ hasRHS(expr().bind(RHSId)),
+ unless(hasRHS(hasDescendant(cxxBoolLiteral())))),
this);
}
@@ -284,9 +286,10 @@ void SimplifyBooleanExprCheck::matchExpr
binaryOperator(
isExpansionInMainFile(), hasOperatorName(OperatorName),
hasLHS(expr().bind(LHSId)),
- unless(hasLHS(anyOf(boolLiteral(), hasDescendant(boolLiteral())))),
+ unless(
+ hasLHS(anyOf(cxxBoolLiteral(), hasDescendant(cxxBoolLiteral())))),
hasRHS(allOf(expr().bind(RHSId),
- boolLiteral(equals(Value)).bind(BooleanId)))),
+ cxxBoolLiteral(equals(Value)).bind(BooleanId)))),
this);
}
@@ -297,10 +300,10 @@ void SimplifyBooleanExprCheck::matchBool
Finder->addMatcher(
binaryOperator(isExpansionInMainFile(), hasOperatorName(OperatorName),
hasLHS(allOf(expr().bind(LHSId),
- ignoringImpCasts(boolLiteral(equals(Value))
+ ignoringImpCasts(cxxBoolLiteral(equals(Value))
.bind(BooleanId)))),
hasRHS(expr().bind(RHSId)),
- unless(hasRHS(hasDescendant(boolLiteral())))),
+ unless(hasRHS(hasDescendant(cxxBoolLiteral())))),
this);
}
@@ -310,10 +313,10 @@ void SimplifyBooleanExprCheck::matchExpr
StringRef BooleanId) {
Finder->addMatcher(
binaryOperator(isExpansionInMainFile(), hasOperatorName(OperatorName),
- unless(hasLHS(hasDescendant(boolLiteral()))),
+ unless(hasLHS(hasDescendant(cxxBoolLiteral()))),
hasLHS(expr().bind(LHSId)),
hasRHS(allOf(expr().bind(RHSId),
- ignoringImpCasts(boolLiteral(equals(Value))
+ ignoringImpCasts(cxxBoolLiteral(equals(Value))
.bind(BooleanId))))),
this);
}
@@ -323,7 +326,7 @@ void SimplifyBooleanExprCheck::matchBool
StringRef BooleanId) {
Finder->addMatcher(
ifStmt(isExpansionInMainFile(),
- hasCondition(boolLiteral(equals(Value)).bind(BooleanId)))
+ hasCondition(cxxBoolLiteral(equals(Value)).bind(BooleanId)))
.bind(IfStmtId),
this);
}
@@ -333,8 +336,8 @@ void SimplifyBooleanExprCheck::matchTern
StringRef TernaryId) {
Finder->addMatcher(
conditionalOperator(isExpansionInMainFile(),
- hasTrueExpression(boolLiteral(equals(Value))),
- hasFalseExpression(boolLiteral(equals(!Value))))
+ hasTrueExpression(cxxBoolLiteral(equals(Value))),
+ hasFalseExpression(cxxBoolLiteral(equals(!Value))))
.bind(TernaryId),
this);
}
@@ -363,13 +366,13 @@ void SimplifyBooleanExprCheck::matchIfAs
hasOperatorName("="),
hasLHS(declRefExpr(hasDeclaration(decl().bind(IfAssignObjId)))),
hasLHS(expr().bind(IfAssignVariableId)),
- hasRHS(boolLiteral(equals(Value)).bind(IfAssignLocId)));
+ hasRHS(cxxBoolLiteral(equals(Value)).bind(IfAssignLocId)));
auto Then = anyOf(SimpleThen, compoundStmt(statementCountIs(1),
hasAnySubstatement(SimpleThen)));
auto SimpleElse = binaryOperator(
hasOperatorName("="),
hasLHS(declRefExpr(hasDeclaration(equalsBoundNode(IfAssignObjId)))),
- hasRHS(boolLiteral(equals(!Value))));
+ hasRHS(cxxBoolLiteral(equals(!Value))));
auto Else = anyOf(SimpleElse, compoundStmt(statementCountIs(1),
hasAnySubstatement(SimpleElse)));
if (ChainedConditionalAssignment) {
@@ -389,11 +392,11 @@ void SimplifyBooleanExprCheck::matchComp
bool Value,
StringRef Id) {
Finder->addMatcher(
- compoundStmt(
- allOf(hasAnySubstatement(ifStmt(hasThen(returnsBool(Value)),
- unless(hasElse(stmt())))),
- hasAnySubstatement(returnStmt(has(boolLiteral(equals(!Value))))
- .bind(CompoundReturnId))))
+ compoundStmt(allOf(hasAnySubstatement(ifStmt(hasThen(returnsBool(Value)),
+ unless(hasElse(stmt())))),
+ hasAnySubstatement(
+ returnStmt(has(cxxBoolLiteral(equals(!Value))))
+ .bind(CompoundReturnId))))
.bind(Id),
this);
}
More information about the cfe-commits
mailing list