[llvm-branch-commits] [cfe-branch] r159535 - in /cfe/branches/tooling: examples/rename-method/ include/clang/ASTMatchers/ include/clang/ASTMatchers/Dynamic/ lib/ASTMatchers/Dynamic/ tools/fix-llvm-style/ tools/remove-cstr-calls/ unittests/ASTMatchers/ unittests/ASTMatchers/Dynamic/
Manuel Klimek
klimek at google.com
Mon Jul 2 09:15:57 PDT 2012
Author: klimek
Date: Mon Jul 2 11:15:56 2012
New Revision: 159535
URL: http://llvm.org/viewvc/llvm-project?rev=159535&view=rev
Log:
Ran fix-llvm-style on the matchers without an exception for
matcher generators.
This is the first step adapting the matcher-generator functions
to camelCase style.
Modified:
cfe/branches/tooling/examples/rename-method/RenameMethod.cpp
cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchers.h
cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchersInternal.h
cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchersMacros.h
cfe/branches/tooling/include/clang/ASTMatchers/Dynamic/GenericMatcher.h
cfe/branches/tooling/include/clang/ASTMatchers/Dynamic/GenericValue.h
cfe/branches/tooling/lib/ASTMatchers/Dynamic/Marshallers.h
cfe/branches/tooling/lib/ASTMatchers/Dynamic/Parser.cpp
cfe/branches/tooling/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/branches/tooling/tools/fix-llvm-style/FixLLVMStyle.cpp
cfe/branches/tooling/tools/remove-cstr-calls/RemoveCStrCalls.cpp
cfe/branches/tooling/unittests/ASTMatchers/ASTMatchersTest.cpp
cfe/branches/tooling/unittests/ASTMatchers/Dynamic/GenericMatcherTest.cpp
cfe/branches/tooling/unittests/ASTMatchers/Dynamic/ParserTest.cpp
cfe/branches/tooling/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
Modified: cfe/branches/tooling/examples/rename-method/RenameMethod.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/examples/rename-method/RenameMethod.cpp?rev=159535&r1=159534&r2=159535&view=diff
==============================================================================
--- cfe/branches/tooling/examples/rename-method/RenameMethod.cpp (original)
+++ cfe/branches/tooling/examples/rename-method/RenameMethod.cpp Mon Jul 2 11:15:56 2012
@@ -124,21 +124,21 @@
// Match calls...
Call(
// Where the callee is a method called "Get"...
- Callee(Method(HasName("Get"))),
+ callee(Method(hasName("Get"))),
// ... and the class on which the method is called is derived
// from ElementsBase ...
- ThisPointerType(Class(
- IsDerivedFrom("ElementsBase"))),
+ thisPointerType(Class(
+ isDerivedFrom("ElementsBase"))),
// ... and bind the member expression to the ID "member", under which
// it can later be found in the callback.
- Callee(Id("member", MemberExpression()))),
+ callee(id("member", MemberExpression()))),
&CallCallback);
DeclRenamer DeclCallback(&Tool.getReplacements());
Finder.addMatcher(
// Match declarations...
- Id("method", Method(HasName("Get"),
- OfClass(IsDerivedFrom("ElementsBase")))),
+ id("method", Method(hasName("Get"),
+ ofClass(isDerivedFrom("ElementsBase")))),
&DeclCallback);
return Tool.run(newFrontendActionFactory(&Finder));
Modified: cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchers.h?rev=159535&r1=159534&r2=159535&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchers.h Mon Jul 2 11:15:56 2012
@@ -101,7 +101,7 @@
///
/// FIXME: Add example for accessing it.
template <typename T>
-internal::Matcher<T> Id(const std::string &ID,
+internal::Matcher<T> id(const std::string &ID,
const internal::Matcher<T> &InnerMatcher) {
return internal::Matcher<T>(new internal::IdMatcher<T>(ID, InnerMatcher));
}
@@ -124,7 +124,7 @@
/// "int* p" and "void f()" in
/// int* p;
/// void f();
-inline internal::PolymorphicMatcherWithParam0<internal::TrueMatcher> True() {
+inline internal::PolymorphicMatcherWithParam0<internal::TrueMatcher> anything() {
return internal::PolymorphicMatcherWithParam0<internal::TrueMatcher>();
}
@@ -517,22 +517,22 @@
/// @{
template<typename C1, typename C2>
internal::PolymorphicMatcherWithParam2<internal::AnyOfMatcher, C1, C2>
-AnyOf(const C1 &P1, const C2 &P2) {
+anyOf(const C1 &P1, const C2 &P2) {
return internal::PolymorphicMatcherWithParam2<internal::AnyOfMatcher,
C1, C2 >(P1, P2);
}
template<typename C1, typename C2, typename C3>
internal::PolymorphicMatcherWithParam2<internal::AnyOfMatcher, C1,
internal::PolymorphicMatcherWithParam2<internal::AnyOfMatcher, C2, C3> >
-AnyOf(const C1 &P1, const C2 &P2, const C3 &P3) {
- return AnyOf(P1, AnyOf(P2, P3));
+anyOf(const C1 &P1, const C2 &P2, const C3 &P3) {
+ return anyOf(P1, anyOf(P2, P3));
}
template<typename C1, typename C2, typename C3, typename C4>
internal::PolymorphicMatcherWithParam2<internal::AnyOfMatcher, C1,
internal::PolymorphicMatcherWithParam2<internal::AnyOfMatcher, C2,
internal::PolymorphicMatcherWithParam2<internal::AnyOfMatcher,
C3, C4> > >
-AnyOf(const C1 &P1, const C2 &P2, const C3 &P3, const C4 &P4) {
+anyOf(const C1 &P1, const C2 &P2, const C3 &P3, const C4 &P4) {
return AnyOf(P1, AnyOf(P2, AnyOf(P3, P4)));
}
template<typename C1, typename C2, typename C3, typename C4, typename C5>
@@ -541,8 +541,8 @@
internal::PolymorphicMatcherWithParam2<internal::AnyOfMatcher, C3,
internal::PolymorphicMatcherWithParam2<internal::AnyOfMatcher,
C4, C5> > > >
-AnyOf(const C1& P1, const C2& P2, const C3& P3, const C4& P4, const C5& P5) {
- return AnyOf(P1, AnyOf(P2, AnyOf(P3, AnyOf(P4, P5))));
+anyOf(const C1& P1, const C2& P2, const C3& P3, const C4& P4, const C5& P5) {
+ return anyOf(P1, anyOf(P2, anyOf(P3, anyOf(P4, P5))));
}
/// @}
@@ -550,14 +550,14 @@
/// @{
template<typename C1, typename C2>
internal::PolymorphicMatcherWithParam2<internal::AllOfMatcher, C1, C2>
-AllOf(const C1 &P1, const C2 &P2) {
+allOf(const C1 &P1, const C2 &P2) {
return internal::PolymorphicMatcherWithParam2<internal::AllOfMatcher,
C1, C2>(P1, P2);
}
template<typename C1, typename C2, typename C3>
internal::PolymorphicMatcherWithParam2<internal::AllOfMatcher, C1,
internal::PolymorphicMatcherWithParam2<internal::AllOfMatcher, C2, C3> >
-AllOf(const C1& P1, const C2& P2, const C3& P3) {
+allOf(const C1& P1, const C2& P2, const C3& P3) {
return AllOf(P1, AllOf(P2, P3));
}
/// @}
@@ -573,7 +573,7 @@
///
/// Example matches X (name is one of "::a::b::X", "a::b::X", "b::X", "X")
/// namespace a { namespace b { class X; } }
-AST_MATCHER_P(clang::NamedDecl, HasName, std::string, Name) {
+AST_MATCHER_P(clang::NamedDecl, hasName, std::string, Name) {
assert(!Name.empty());
const std::string FullNameString = "::" + Node.getQualifiedNameAsString();
const llvm::StringRef FullName = FullNameString;
@@ -596,7 +596,7 @@
/// c && d; // assuming both operator<<
/// // and operator&& are overloaded somewhere.
AST_MATCHER_P(clang::CXXOperatorCallExpr,
- HasOverloadedOperatorName, std::string, Name) {
+ hasOverloadedOperatorName, std::string, Name) {
return clang::getOperatorSpelling(Node.getOperator()) == Name;
}
@@ -620,7 +620,7 @@
/// class Foo;
/// typedef Foo X;
/// class Bar : public Foo {}; // derived from a type that X is a typedef of
-AST_MATCHER_P(clang::CXXRecordDecl, IsDerivedFrom, std::string, Base) {
+AST_MATCHER_P(clang::CXXRecordDecl, isDerivedFrom, std::string, Base) {
assert(!Base.empty());
return Finder->classIsDerivedFrom(&Node, Base);
}
@@ -713,7 +713,7 @@
/// class X {};
/// class Y {};
template <typename M>
-internal::PolymorphicMatcherWithParam1<internal::NotMatcher, M> Not(const M &InnerMatcher) {
+internal::PolymorphicMatcherWithParam1<internal::NotMatcher, M> unless(const M &InnerMatcher) {
return internal::PolymorphicMatcherWithParam1<
internal::NotMatcher, M>(InnerMatcher);
}
@@ -722,7 +722,7 @@
/// matcher.
inline internal::PolymorphicMatcherWithParam1< internal::HasDeclarationMatcher,
internal::Matcher<clang::Decl> >
- HasDeclaration(const internal::Matcher<clang::Decl> &InnerMatcher) {
+ hasDeclaration(const internal::Matcher<clang::Decl> &InnerMatcher) {
return internal::PolymorphicMatcherWithParam1<
internal::HasDeclarationMatcher,
internal::Matcher<clang::Decl> >(InnerMatcher);
@@ -735,7 +735,7 @@
/// void z() { Y y; y.x(); }",
///
/// FIXME: Overload to allow directly matching types?
-AST_MATCHER_P(clang::CXXMemberCallExpr, On, internal::Matcher<clang::Expr>,
+AST_MATCHER_P(clang::CXXMemberCallExpr, on, internal::Matcher<clang::Expr>,
InnerMatcher) {
const clang::Expr *ExprNode = const_cast<clang::CXXMemberCallExpr&>(Node)
.getImplicitObjectArgument()
@@ -758,7 +758,7 @@
/// this introduces ambiguous overloads with calls to Callee taking a
/// internal::Matcher<clang::Decl>, as the matcher hierarchy is purely implemented in
/// terms of implicit casts.
-AST_MATCHER_P(clang::CallExpr, Callee, internal::Matcher<clang::Stmt>,
+AST_MATCHER_P(clang::CallExpr, callee, internal::Matcher<clang::Stmt>,
InnerMatcher) {
const clang::Expr *ExprNode = Node.getCallee();
return (ExprNode != NULL &&
@@ -771,9 +771,9 @@
/// Example matches y.x() (matcher = Call(Callee(Method(HasName("x")))))
/// class Y { public: void x(); };
/// void z() { Y y; y.x();
-inline internal::Matcher<clang::CallExpr> Callee(
+inline internal::Matcher<clang::CallExpr> callee(
const internal::Matcher<clang::Decl> &InnerMatcher) {
- return internal::Matcher<clang::CallExpr>(HasDeclaration(InnerMatcher));
+ return internal::Matcher<clang::CallExpr>(hasDeclaration(InnerMatcher));
}
/// \brief Matches if the expression's or declaration's type matches a type
@@ -785,7 +785,7 @@
/// HasDeclaration(Class(HasName("X"))))))
/// class X {};
/// void y(X &x) { x; X z; }
-AST_POLYMORPHIC_MATCHER_P(HasType, internal::Matcher<clang::QualType>,
+AST_POLYMORPHIC_MATCHER_P(hasType, internal::Matcher<clang::QualType>,
InnerMatcher) {
TOOLING_COMPILE_ASSERT((llvm::is_base_of<clang::Expr, NodeType>::value ||
llvm::is_base_of<clang::ValueDecl, NodeType>::value),
@@ -807,11 +807,11 @@
/// class X {};
/// void y(X &x) { x; X z; }
inline internal::PolymorphicMatcherWithParam1<
- internal::matcher_HasTypeMatcher,
+ internal::matcher_hasTypeMatcher,
internal::Matcher<clang::QualType> >
-HasType(const internal::Matcher<clang::Decl> &InnerMatcher) {
- return HasType(internal::Matcher<clang::QualType>(
- HasDeclaration(InnerMatcher)));
+hasType(const internal::Matcher<clang::Decl> &InnerMatcher) {
+ return hasType(internal::Matcher<clang::QualType>(
+ hasDeclaration(InnerMatcher)));
}
/// \brief Matches if the matched type is a pointer type and the pointee type
@@ -822,17 +822,17 @@
/// class Y { public: void x(); };
/// void z() { Y *y; y->x(); }
AST_MATCHER_P(
- clang::QualType, PointsTo, internal::Matcher<clang::QualType>,
+ clang::QualType, pointsTo, internal::Matcher<clang::QualType>,
InnerMatcher) {
return (Node->isPointerType() &&
InnerMatcher.matches(Node->getPointeeType(), Finder, Builder));
}
/// \brief Overloaded to match the pointee type's declaration.
-inline internal::Matcher<clang::QualType> PointsTo(
+inline internal::Matcher<clang::QualType> pointsTo(
const internal::Matcher<clang::Decl> &InnerMatcher) {
- return PointsTo(internal::Matcher<clang::QualType>(
- HasDeclaration(InnerMatcher)));
+ return pointsTo(internal::Matcher<clang::QualType>(
+ hasDeclaration(InnerMatcher)));
}
/// \brief Matches if the matched type is a reference type and the referenced
@@ -845,20 +845,20 @@
/// X &x = b;
/// const X &y = b;
/// };
-AST_MATCHER_P(clang::QualType, References, internal::Matcher<clang::QualType>,
+AST_MATCHER_P(clang::QualType, references, internal::Matcher<clang::QualType>,
InnerMatcher) {
return (Node->isReferenceType() &&
InnerMatcher.matches(Node->getPointeeType(), Finder, Builder));
}
/// \brief Overloaded to match the referenced type's declaration.
-inline internal::Matcher<clang::QualType> References(
+inline internal::Matcher<clang::QualType> references(
const internal::Matcher<clang::Decl> &InnerMatcher) {
- return References(internal::Matcher<clang::QualType>(
- HasDeclaration(InnerMatcher)));
+ return references(internal::Matcher<clang::QualType>(
+ hasDeclaration(InnerMatcher)));
}
-AST_MATCHER_P(clang::CXXMemberCallExpr, OnImplicitObjectArgument,
+AST_MATCHER_P(clang::CXXMemberCallExpr, onImplicitObjectArgument,
internal::Matcher<clang::Expr>, InnerMatcher) {
const clang::Expr *ExprNode =
const_cast<clang::CXXMemberCallExpr&>(Node).getImplicitObjectArgument();
@@ -868,17 +868,17 @@
/// \brief Matches if the expression's type either matches the specified
/// matcher, or is a pointer to a type that matches the InnerMatcher.
-inline internal::Matcher<clang::CallExpr> ThisPointerType(
+inline internal::Matcher<clang::CallExpr> thisPointerType(
const internal::Matcher<clang::QualType> &InnerMatcher) {
- return OnImplicitObjectArgument(
- AnyOf(HasType(InnerMatcher), HasType(PointsTo(InnerMatcher))));
+ return onImplicitObjectArgument(
+ anyOf(hasType(InnerMatcher), hasType(pointsTo(InnerMatcher))));
}
/// \brief Overloaded to match the type's declaration.
-inline internal::Matcher<clang::CallExpr> ThisPointerType(
+inline internal::Matcher<clang::CallExpr> thisPointerType(
const internal::Matcher<clang::Decl> &InnerMatcher) {
- return OnImplicitObjectArgument(
- AnyOf(HasType(InnerMatcher), HasType(PointsTo(InnerMatcher))));
+ return onImplicitObjectArgument(
+ anyOf(hasType(InnerMatcher), hasType(pointsTo(InnerMatcher))));
}
/// \brief Matches a DeclRefExpr that refers to a declaration that matches the
@@ -888,7 +888,7 @@
/// (matcher = DeclarationReference(To(Variable(HasName("x")))))
/// bool x;
/// if (x) {}
-AST_MATCHER_P(clang::DeclRefExpr, To, internal::Matcher<clang::Decl>,
+AST_MATCHER_P(clang::DeclRefExpr, to, internal::Matcher<clang::Decl>,
InnerMatcher) {
const clang::Decl *DeclNode = Node.getDecl();
return (DeclNode != NULL &&
@@ -902,7 +902,7 @@
/// bool y() { return true; }
/// bool x = y();
AST_MATCHER_P(
- clang::VarDecl, HasInitializer, internal::Matcher<clang::Expr>,
+ clang::VarDecl, hasInitializer, internal::Matcher<clang::Expr>,
InnerMatcher) {
const clang::Expr *Initializer = Node.getAnyInitializer();
return (Initializer != NULL &&
@@ -915,7 +915,7 @@
/// Example matches f(0, 0) (matcher = Call(ArgumentCountIs(2)))
/// void f(int x, int y);
/// f(0, 0);
-AST_POLYMORPHIC_MATCHER_P(ArgumentCountIs, unsigned, N) {
+AST_POLYMORPHIC_MATCHER_P(argumentCountIs, unsigned, N) {
TOOLING_COMPILE_ASSERT((llvm::is_base_of<clang::CallExpr, NodeType>::value ||
llvm::is_base_of<clang::CXXConstructExpr,
NodeType>::value),
@@ -930,7 +930,7 @@
/// (matcher = Call(HasArgument(0, DeclarationReference())))
/// void x(int) { int y; x(y); }
AST_POLYMORPHIC_MATCHER_P2(
- HasArgument, unsigned, N, internal::Matcher<clang::Expr>, InnerMatcher) {
+ hasArgument, unsigned, N, internal::Matcher<clang::Expr>, InnerMatcher) {
TOOLING_COMPILE_ASSERT((llvm::is_base_of<clang::CallExpr, NodeType>::value ||
llvm::is_base_of<clang::CXXConstructExpr,
NodeType>::value),
@@ -949,7 +949,7 @@
/// };
/// Class(Has(Constructor(HasAnyConstructorInitializer(True()))))
/// Class matches Foo, HasAnyConstructorInitializer matches foo_(1)
-AST_MATCHER_P(clang::CXXConstructorDecl, HasAnyConstructorInitializer,
+AST_MATCHER_P(clang::CXXConstructorDecl, hasAnyConstructorInitializer,
internal::Matcher<clang::CXXCtorInitializer>, InnerMatcher) {
for (clang::CXXConstructorDecl::init_const_iterator I = Node.init_begin();
I != Node.init_end(); ++I) {
@@ -971,7 +971,7 @@
/// ForField(HasName("foo_"))))))
/// matches Foo
/// with ForField matching foo_
-AST_MATCHER_P(clang::CXXCtorInitializer, ForField,
+AST_MATCHER_P(clang::CXXCtorInitializer, forField,
internal::Matcher<clang::FieldDecl>, InnerMatcher) {
const clang::FieldDecl *NodeAsDecl = Node.getMember();
return (NodeAsDecl != NULL &&
@@ -989,7 +989,7 @@
/// WithInitializer(IntegerLiteral(Equals(1)))))))
/// matches Foo
/// with WithInitializer matching (1)
-AST_MATCHER_P(clang::CXXCtorInitializer, WithInitializer,
+AST_MATCHER_P(clang::CXXCtorInitializer, withInitializer,
internal::Matcher<clang::Expr>, InnerMatcher) {
const clang::Expr* NodeAsExpr = Node.getInit();
return (NodeAsExpr != NULL &&
@@ -1007,13 +1007,13 @@
/// };
/// Constructor(HasAnyConstructorInitializer(IsWritten()))
/// will match Foo(int), but not Foo()
-AST_MATCHER(clang::CXXCtorInitializer, IsWritten) {
+AST_MATCHER(clang::CXXCtorInitializer, isWritten) {
return Node.isWritten();
}
/// \brief Matches a constructor declaration that has been implicitly added
/// by the compiler (eg. implicit default/copy constructors).
-AST_MATCHER(clang::CXXConstructorDecl, IsImplicit) {
+AST_MATCHER(clang::CXXConstructorDecl, isImplicit) {
return Node.isImplicit();
}
@@ -1026,7 +1026,7 @@
/// matches x(1, y, 42)
/// with HasAnyArgument(...)
/// matching y
-AST_POLYMORPHIC_MATCHER_P(HasAnyArgument, internal::Matcher<clang::Expr>,
+AST_POLYMORPHIC_MATCHER_P(hasAnyArgument, internal::Matcher<clang::Expr>,
InnerMatcher) {
TOOLING_COMPILE_ASSERT((llvm::is_base_of<clang::CallExpr, NodeType>::value ||
llvm::is_base_of<clang::CXXConstructExpr,
@@ -1049,7 +1049,7 @@
/// matches f(int x) {}
/// with HasParameter(...)
/// matching int x
-AST_MATCHER_P2(clang::FunctionDecl, HasParameter,
+AST_MATCHER_P2(clang::FunctionDecl, hasParameter,
unsigned, N, internal::Matcher<clang::ParmVarDecl>,
InnerMatcher) {
return (N < Node.getNumParams() &&
@@ -1067,7 +1067,7 @@
/// matches f(int x, int y, int z) {}
/// with HasAnyParameter(...)
/// matching int y
-AST_MATCHER_P(clang::FunctionDecl, HasAnyParameter,
+AST_MATCHER_P(clang::FunctionDecl, hasAnyParameter,
internal::Matcher<clang::ParmVarDecl>, InnerMatcher) {
for (unsigned I = 0; I < Node.getNumParams(); ++I) {
if (InnerMatcher.matches(*Node.getParamDecl(I), Finder, Builder)) {
@@ -1082,7 +1082,7 @@
///
/// Example matches true (matcher = HasCondition(BoolLiteral(Equals(true))))
/// if (true) {}
-AST_POLYMORPHIC_MATCHER_P(HasCondition, internal::Matcher<clang::Expr>,
+AST_POLYMORPHIC_MATCHER_P(hasCondition, internal::Matcher<clang::Expr>,
InnerMatcher) {
TOOLING_COMPILE_ASSERT(
(llvm::is_base_of<clang::IfStmt, NodeType>::value) ||
@@ -1099,7 +1099,7 @@
/// if (A* a = GetAPointer()) {}
/// HasConditionVariableStatment(...)
/// matches 'A* a = GetAPointer()'.
-AST_MATCHER_P(clang::IfStmt, HasConditionVariableStatement,
+AST_MATCHER_P(clang::IfStmt, hasConditionVariableStatement,
internal::Matcher<clang::DeclStmt>, InnerMatcher) {
const clang::DeclStmt* const DeclarationStatement =
Node.getConditionVariableDeclStmt();
@@ -1115,7 +1115,7 @@
/// matches 'for (;;) {}'
/// with CompoundStatement()
/// matching '{}'
-AST_MATCHER_P(clang::ForStmt, HasBody, internal::Matcher<clang::Stmt>,
+AST_MATCHER_P(clang::ForStmt, hasBody, internal::Matcher<clang::Stmt>,
InnerMatcher) {
const clang::Stmt *const Statement = Node.getBody();
return (Statement != NULL &&
@@ -1131,7 +1131,7 @@
/// matches '{ {}; 1+2; }'
/// with CompoundStatement()
/// matching '{}'
-AST_MATCHER_P(clang::CompoundStmt, HasAnySubstatement,
+AST_MATCHER_P(clang::CompoundStmt, hasAnySubstatement,
internal::Matcher<clang::Stmt>, InnerMatcher) {
for (clang::CompoundStmt::const_body_iterator It = Node.body_begin();
It != Node.body_end();
@@ -1149,7 +1149,7 @@
/// CompoundStatement(StatementCountIs(0)))
/// matches '{}'
/// but does not match the outer compound statement.
-AST_MATCHER_P(clang::CompoundStmt, StatementCountIs, unsigned, N) {
+AST_MATCHER_P(clang::CompoundStmt, statementCountIs, unsigned, N) {
return Node.size() == N;
}
@@ -1159,7 +1159,7 @@
/// true
template <typename ValueT>
internal::PolymorphicMatcherWithParam1<internal::ValueEqualsMatcher, ValueT>
-Equals(const ValueT &Value) {
+equals(const ValueT &Value) {
return internal::PolymorphicMatcherWithParam1<
internal::ValueEqualsMatcher,
ValueT>(Value);
@@ -1170,7 +1170,7 @@
///
/// Example matches a || b (matcher = BinaryOperator(HasOperatorName("||")))
/// !(a || b)
-AST_POLYMORPHIC_MATCHER_P(HasOperatorName, std::string, Name) {
+AST_POLYMORPHIC_MATCHER_P(hasOperatorName, std::string, Name) {
TOOLING_COMPILE_ASSERT(
(llvm::is_base_of<clang::BinaryOperator, NodeType>::value) ||
(llvm::is_base_of<clang::UnaryOperator, NodeType>::value),
@@ -1182,7 +1182,7 @@
///
/// Example matches a (matcher = BinaryOperator(HasLHS()))
/// a || b
-AST_MATCHER_P(clang::BinaryOperator, HasLHS,
+AST_MATCHER_P(clang::BinaryOperator, hasLHS,
internal::Matcher<clang::Expr>, InnerMatcher) {
clang::Expr *LeftHandSide = Node.getLHS();
return (LeftHandSide != NULL &&
@@ -1193,7 +1193,7 @@
///
/// Example matches b (matcher = BinaryOperator(HasRHS()))
/// a || b
-AST_MATCHER_P(clang::BinaryOperator, HasRHS,
+AST_MATCHER_P(clang::BinaryOperator, hasRHS,
internal::Matcher<clang::Expr>, InnerMatcher) {
clang::Expr *RightHandSide = Node.getRHS();
return (RightHandSide != NULL &&
@@ -1202,16 +1202,16 @@
/// \brief Matches if either the left hand side or the right hand side of a
/// binary operator matches.
-inline internal::Matcher<clang::BinaryOperator> HasEitherOperand(
+inline internal::Matcher<clang::BinaryOperator> hasEitherOperand(
const internal::Matcher<clang::Expr> &InnerMatcher) {
- return AnyOf(HasLHS(InnerMatcher), HasRHS(InnerMatcher));
+ return anyOf(hasLHS(InnerMatcher), hasRHS(InnerMatcher));
}
/// \brief Matches if the operand of a unary operator matches.
///
/// Example matches true (matcher = HasOperand(BoolLiteral(Equals(true))))
/// !true
-AST_MATCHER_P(clang::UnaryOperator, HasUnaryOperand,
+AST_MATCHER_P(clang::UnaryOperator, hasUnaryOperand,
internal::Matcher<clang::Expr>, InnerMatcher) {
const clang::Expr * const Operand = Node.getSubExpr();
return (Operand != NULL &&
@@ -1225,7 +1225,7 @@
///
/// class URL { URL(string); };
/// URL url = "a string";
-AST_MATCHER_P(clang::ImplicitCastExpr, HasSourceExpression,
+AST_MATCHER_P(clang::ImplicitCastExpr, hasSourceExpression,
internal::Matcher<clang::Expr>, InnerMatcher) {
const clang::Expr* const SubExpression = Node.getSubExpr();
return (SubExpression != NULL &&
@@ -1236,7 +1236,7 @@
///
/// (Note: Clang's AST refers to other conversions as "casts" too, and calls
/// actual casts "explicit" casts.)
-AST_MATCHER_P(clang::ExplicitCastExpr, HasDestinationType,
+AST_MATCHER_P(clang::ExplicitCastExpr, hasDestinationType,
internal::Matcher<clang::QualType>, InnerMatcher) {
const clang::QualType NodeType = Node.getTypeAsWritten();
return InnerMatcher.matches(NodeType, Finder, Builder);
@@ -1246,7 +1246,7 @@
/// matcher.
///
/// FIXME: Unit test this matcher
-AST_MATCHER_P(clang::ImplicitCastExpr, HasImplicitDestinationType,
+AST_MATCHER_P(clang::ImplicitCastExpr, hasImplicitDestinationType,
internal::Matcher<clang::QualType>, InnerMatcher) {
return InnerMatcher.matches(Node.getType(), Finder, Builder);
}
@@ -1255,7 +1255,7 @@
///
/// Example matches a
/// condition ? a : b
-AST_MATCHER_P(clang::ConditionalOperator, HasTrueExpression,
+AST_MATCHER_P(clang::ConditionalOperator, hasTrueExpression,
internal::Matcher<clang::Expr>, InnerMatcher) {
clang::Expr *Expression = Node.getTrueExpr();
return (Expression != NULL &&
@@ -1266,7 +1266,7 @@
///
/// Example matches b
/// condition ? a : b
-AST_MATCHER_P(clang::ConditionalOperator, HasFalseExpression,
+AST_MATCHER_P(clang::ConditionalOperator, hasFalseExpression,
internal::Matcher<clang::Expr>, InnerMatcher) {
clang::Expr *Expression = Node.getFalseExpr();
return (Expression != NULL &&
@@ -1283,7 +1283,7 @@
/// void fa() {}
/// void fb(); // Doesn't match, as it has no body.
inline internal::PolymorphicMatcherWithParam0<internal::IsDefinitionMatcher>
-IsDefinition() {
+isDefinition() {
return internal::PolymorphicMatcherWithParam0<
internal::IsDefinitionMatcher>();
}
@@ -1303,7 +1303,7 @@
/// A();
/// };
/// A a = A();
-AST_MATCHER_P(clang::CXXMethodDecl, OfClass,
+AST_MATCHER_P(clang::CXXMethodDecl, ofClass,
internal::Matcher<clang::CXXRecordDecl>, InnerMatcher) {
const clang::CXXRecordDecl *Parent = Node.getParent();
return (Parent != NULL &&
@@ -1323,8 +1323,8 @@
/// };
/// MemberExpression(IsArrow())
/// matches this->x, x, y.x, a, this->b
-inline internal::Matcher<clang::MemberExpr> IsArrow() {
- return MakeMatcher(new internal::IsArrowMatcher());
+inline internal::Matcher<clang::MemberExpr> isArrow() {
+ return makeMatcher(new internal::IsArrowMatcher());
}
/// \brief Matches clang::QualType nodes that are const-qualified, i.e., that
@@ -1340,8 +1340,8 @@
/// matches "void b(int const)", "void c(const int)" and
/// "void e(int const) {}". It does not match d as there
/// is no top-level const on the parameter type "const int *".
-inline internal::Matcher<clang::QualType> IsConstQualified() {
- return MakeMatcher(new internal::IsConstQualifiedMatcher());
+inline internal::Matcher<clang::QualType> isConstQualified() {
+ return makeMatcher(new internal::IsConstQualifiedMatcher());
}
/// \brief Matches a member expression where the member is matched by a
@@ -1354,7 +1354,7 @@
/// MemberExpression(Member(HasName("first")))
/// matches second.first
/// but not first.second (because the member name there is "second").
-AST_MATCHER_P(clang::MemberExpr, Member,
+AST_MATCHER_P(clang::MemberExpr, member,
internal::Matcher<clang::ValueDecl>, InnerMatcher) {
return InnerMatcher.matches(*Node.getMemberDecl(), Finder, Builder);
}
@@ -1369,7 +1369,7 @@
/// matches "x.m" and "m"
/// with HasObjectExpression(...)
/// matching "x" and the implicit object expression of "m" which has type X*.
-AST_MATCHER_P(clang::MemberExpr, HasObjectExpression,
+AST_MATCHER_P(clang::MemberExpr, hasObjectExpression,
internal::Matcher<clang::Expr>, InnerMatcher) {
return InnerMatcher.matches(*Node.getBase(), Finder, Builder);
}
@@ -1391,7 +1391,7 @@
/// does not match, as X<A> is an explicit template specialization.
inline internal::PolymorphicMatcherWithParam0<
internal::IsTemplateInstantiationMatcher>
-IsTemplateInstantiation() {
+isTemplateInstantiation() {
return internal::PolymorphicMatcherWithParam0<
internal::IsTemplateInstantiationMatcher>();
}
Modified: cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchersInternal.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchersInternal.h?rev=159535&r1=159534&r2=159535&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchersInternal.h (original)
+++ cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchersInternal.h Mon Jul 2 11:15:56 2012
@@ -251,7 +251,7 @@
/// \brief A convenient helper for creating a Matcher<T> without specifying
/// the template type argument.
template <typename T>
-inline Matcher<T> MakeMatcher(MatcherInterface<T> *Implementation) {
+inline Matcher<T> makeMatcher(MatcherInterface<T> *Implementation) {
return Matcher<T>(Implementation);
}
@@ -575,7 +575,7 @@
template <>
inline Matcher<clang::CXXMemberCallExpr>::
operator Matcher<clang::CallExpr>() const {
- return MakeMatcher(
+ return makeMatcher(
new DynCastMatcher<clang::CallExpr, clang::CXXMemberCallExpr>(*this));
}
@@ -727,15 +727,15 @@
/// \brief Creates a Matcher<T> that matches if
/// T is dyn_cast'able into InnerT and all inner matchers match.
template<typename T, typename InnerT>
-Matcher<T> MakeDynCastAllOfComposite(
+Matcher<T> makeDynCastAllOfComposite(
ArrayRef<const Matcher<InnerT> *> InnerMatchers) {
if (InnerMatchers.empty()) {
return ArgumentAdaptingMatcher<DynCastMatcher, InnerT>(
- MakeMatcher(new TrueMatcher<InnerT>));
+ makeMatcher(new TrueMatcher<InnerT>));
}
Matcher<InnerT> InnerMatcher = *InnerMatchers.back();
for (int i = InnerMatchers.size() - 2; i >= 0; --i) {
- InnerMatcher = MakeMatcher(
+ InnerMatcher = makeMatcher(
new AllOfMatcher<InnerT, Matcher<InnerT>, Matcher<InnerT> >(
*InnerMatchers[i], InnerMatcher));
}
@@ -876,7 +876,7 @@
class VariadicDynCastAllOfMatcher
: public llvm::VariadicFunction<
Matcher<SourceT>, Matcher<TargetT>,
- MakeDynCastAllOfComposite<SourceT, TargetT> > {
+ makeDynCastAllOfComposite<SourceT, TargetT> > {
public:
VariadicDynCastAllOfMatcher() {}
};
Modified: cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchersMacros.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchersMacros.h?rev=159535&r1=159534&r2=159535&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchersMacros.h (original)
+++ cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchersMacros.h Mon Jul 2 11:15:56 2012
@@ -60,7 +60,7 @@
}; \
} \
inline internal::Matcher<Type> DefineMatcher() { \
- return internal::MakeMatcher( \
+ return internal::makeMatcher( \
new internal::matcher_##DefineMatcher##Matcher()); \
} \
inline bool internal::matcher_##DefineMatcher##Matcher::matches( \
@@ -95,7 +95,7 @@
}; \
} \
inline internal::Matcher<Type> DefineMatcher(const ParamType &Param) { \
- return internal::MakeMatcher( \
+ return internal::makeMatcher( \
new internal::matcher_##DefineMatcher##Matcher(Param)); \
} \
inline bool internal::matcher_##DefineMatcher##Matcher::matches( \
@@ -135,7 +135,7 @@
} \
inline internal::Matcher<Type> DefineMatcher( \
const ParamType1 &Param1, const ParamType2 &Param2) { \
- return internal::MakeMatcher( \
+ return internal::makeMatcher( \
new internal::matcher_##DefineMatcher##Matcher( \
Param1, Param2)); \
} \
Modified: cfe/branches/tooling/include/clang/ASTMatchers/Dynamic/GenericMatcher.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/ASTMatchers/Dynamic/GenericMatcher.h?rev=159535&r1=159534&r2=159535&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/ASTMatchers/Dynamic/GenericMatcher.h (original)
+++ cfe/branches/tooling/include/clang/ASTMatchers/Dynamic/GenericMatcher.h Mon Jul 2 11:15:56 2012
@@ -55,7 +55,7 @@
template <typename T>
Matcher<T> getAs() const {
- return ast_matchers::internal::MakeMatcher(new UntypedWrapper<T>(Untyped));
+ return ast_matchers::internal::makeMatcher(new UntypedWrapper<T>(Untyped));
}
static GenericMatcher anyOf(const GenericMatcher& First,
@@ -89,7 +89,7 @@
template <typename From, typename To>
static Matcher<From> maybeMakeDynCastMatcher(const Matcher<To>& BaseMatcher,
const From* dummy) {
- return MakeMatcher(
+ return makeMatcher(
new ast_matchers::internal::DynCastMatcher<From, To>(BaseMatcher));
}
template <typename T>
Modified: cfe/branches/tooling/include/clang/ASTMatchers/Dynamic/GenericValue.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/ASTMatchers/Dynamic/GenericValue.h?rev=159535&r1=159534&r2=159535&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/ASTMatchers/Dynamic/GenericValue.h (original)
+++ cfe/branches/tooling/include/clang/ASTMatchers/Dynamic/GenericValue.h Mon Jul 2 11:15:56 2012
@@ -42,11 +42,11 @@
}
~GenericValue() {
- Reset();
+ reset();
}
GenericValue& operator=(const GenericValue& Other) {
- Reset();
+ reset();
switch (Other.Type) {
case VT_String: setImpl(Other.get<std::string>()); break;
case VT_Error: setImpl(Other.get<GenericError>()); break;
@@ -70,7 +70,7 @@
}
private:
- void Reset() {
+ void reset() {
switch (Type) {
case VT_String: delete Value.String; break;
case VT_Error: delete Value.Error; break;
Modified: cfe/branches/tooling/lib/ASTMatchers/Dynamic/Marshallers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/ASTMatchers/Dynamic/Marshallers.h?rev=159535&r1=159534&r2=159535&view=diff
==============================================================================
--- cfe/branches/tooling/lib/ASTMatchers/Dynamic/Marshallers.h (original)
+++ cfe/branches/tooling/lib/ASTMatchers/Dynamic/Marshallers.h Mon Jul 2 11:15:56 2012
@@ -63,7 +63,7 @@
};
template <typename MarshallerType, typename FuncType>
-MatcherCreateCallback* CreateMarshallerCallback(
+MatcherCreateCallback* createMarshallerCallback(
MarshallerType Marshaller,
FuncType Func,
const std::string& MatcherName) {
@@ -88,7 +88,7 @@
// 0-arg marshaller function.
template <typename FuncType, typename ReturnType>
-GenericValue MatcherMarshall0(FuncType Func,
+GenericValue matcherMarshall0(FuncType Func,
const std::string& MatcherName,
const std::vector<GenericValue>& Args) {
CHECK_ARG_COUNT(0);
@@ -97,7 +97,7 @@
// 1-arg marshaller function.
template <typename FuncType, typename ReturnType, typename ArgType1>
-GenericValue MatcherMarshall1(FuncType Func,
+GenericValue matcherMarshall1(FuncType Func,
const std::string& MatcherName,
const std::vector<GenericValue>& Args) {
CHECK_ARG_COUNT(1);
@@ -108,7 +108,7 @@
// 2-arg marshaller function.
template <typename FuncType, typename ReturnType,
typename ArgType1, typename ArgType2>
-GenericValue MatcherMarshall2(FuncType Func,
+GenericValue matcherMarshall2(FuncType Func,
const std::string& MatcherName,
const std::vector<GenericValue>& Args) {
CHECK_ARG_COUNT(2);
@@ -136,7 +136,7 @@
InnerArgs[i] = &References.back();
}
return GenericValue(
- ast_matchers::internal::MakeDynCastAllOfComposite<BaseType>(
+ ast_matchers::internal::makeDynCastAllOfComposite<BaseType>(
ArrayRef<const DerivedMatcherType*>(InnerArgs)));
}
@@ -163,59 +163,59 @@
// 0-arg
template <typename ReturnType, typename PolyReturnType>
-MatcherCreateCallback* MakeMatcherAutoMarshallPoly(
+MatcherCreateCallback* makeMatcherAutoMarshallPoly(
PolyReturnType (*Func)(),
const std::string& MatcherName) {
- return CreateMarshallerCallback(
- MatcherMarshall0<PolyReturnType(*)(), ReturnType>, Func, MatcherName);
+ return createMarshallerCallback(
+ matcherMarshall0<PolyReturnType(*)(), ReturnType>, Func, MatcherName);
}
template <typename ReturnType>
-MatcherCreateCallback* MakeMatcherAutoMarshall(
+MatcherCreateCallback* makeMatcherAutoMarshall(
ReturnType (*Func)(),
const std::string& MatcherName) {
- return MakeMatcherAutoMarshallPoly<ReturnType>(Func, MatcherName);
+ return makeMatcherAutoMarshallPoly<ReturnType>(Func, MatcherName);
}
// 1-arg
template <typename ReturnType, typename PolyReturnType, typename InArgType1>
-MatcherCreateCallback* MakeMatcherAutoMarshallPoly(
+MatcherCreateCallback* makeMatcherAutoMarshallPoly(
PolyReturnType (*Func)(InArgType1),
const std::string& MatcherName) {
typedef typename remove_const_ref<InArgType1>::type ArgType1;
- return CreateMarshallerCallback(
- MatcherMarshall1<PolyReturnType (*)(InArgType1), ReturnType, ArgType1>,
+ return createMarshallerCallback(
+ matcherMarshall1<PolyReturnType (*)(InArgType1), ReturnType, ArgType1>,
Func, MatcherName);
}
template <typename ReturnType, typename InArgType1>
-MatcherCreateCallback* MakeMatcherAutoMarshall(
+MatcherCreateCallback* makeMatcherAutoMarshall(
ReturnType (*Func)(InArgType1),
const std::string& MatcherName) {
- return MakeMatcherAutoMarshallPoly<ReturnType>(Func, MatcherName);
+ return makeMatcherAutoMarshallPoly<ReturnType>(Func, MatcherName);
}
// 2-arg
template <typename ReturnType, typename PolyReturnType,
typename InArgType1, typename InArgType2>
-MatcherCreateCallback* MakeMatcherAutoMarshallPoly(
+MatcherCreateCallback* makeMatcherAutoMarshallPoly(
PolyReturnType (*Func)(InArgType1, InArgType2),
const std::string& MatcherName) {
typedef typename remove_const_ref<InArgType1>::type ArgType1;
typedef typename remove_const_ref<InArgType2>::type ArgType2;
- return CreateMarshallerCallback(
- MatcherMarshall2<PolyReturnType (*)(InArgType1, InArgType2),
+ return createMarshallerCallback(
+ matcherMarshall2<PolyReturnType (*)(InArgType1, InArgType2),
ReturnType, ArgType1, ArgType2>,
Func, MatcherName);
}
template <typename ReturnType, typename InArgType1, typename InArgType2>
-MatcherCreateCallback* MakeMatcherAutoMarshall(
+MatcherCreateCallback* makeMatcherAutoMarshall(
ReturnType (*Func)(InArgType1, InArgType2),
const std::string& MatcherName) {
- return MakeMatcherAutoMarshallPoly<ReturnType>(Func, MatcherName);
+ return makeMatcherAutoMarshallPoly<ReturnType>(Func, MatcherName);
}
// Variadic
template <typename BaseType, typename MatcherType>
-MatcherCreateCallback* MakeMatcherAutoMarshall(
+MatcherCreateCallback* makeMatcherAutoMarshall(
ast_matchers::internal::VariadicDynCastAllOfMatcher<
BaseType, MatcherType> Func,
const std::string& MatcherName) {
Modified: cfe/branches/tooling/lib/ASTMatchers/Dynamic/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/ASTMatchers/Dynamic/Parser.cpp?rev=159535&r1=159534&r2=159535&view=diff
==============================================================================
--- cfe/branches/tooling/lib/ASTMatchers/Dynamic/Parser.cpp (original)
+++ cfe/branches/tooling/lib/ASTMatchers/Dynamic/Parser.cpp Mon Jul 2 11:15:56 2012
@@ -37,7 +37,7 @@
consumeWhitespace();
Parser::TokenInfo Result;
Result.StartLine = Line;
- Result.StartColumn = Column();
+ Result.StartColumn = column();
if (Code.empty()) {
// Nothing to do.
@@ -61,7 +61,7 @@
}
Result.EndLine = Line;
- Result.EndColumn = Column() - 1;
+ Result.EndColumn = column() - 1;
return Result;
}
@@ -103,12 +103,12 @@
llvm::StringRef Code;
llvm::StringRef StartOfLine;
int Line;
- int Column() const {
+ int column() const {
return Code.data() - StartOfLine.data() + 1;
}
};
-char UnescapeCharSequence(llvm::StringRef* Escaped) {
+char unescapeCharSequence(llvm::StringRef* Escaped) {
if (Escaped->empty()) return 0;
char Char = (*Escaped)[0];
*Escaped = Escaped->drop_front();
@@ -136,7 +136,7 @@
return Char;
}
-GenericValue ParseString(const Parser::TokenInfo& Token,
+GenericValue parseString(const Parser::TokenInfo& Token,
Parser::TokenProcessor* Processor) {
if (Token.Token.size() < 2 ||
!Token.Token.startswith("\"") || !Token.Token.endswith("\"")) {
@@ -148,14 +148,14 @@
std::string Unescaped;
while (!Escaped.empty()) {
- Unescaped.push_back(UnescapeCharSequence(&Escaped));
+ Unescaped.push_back(unescapeCharSequence(&Escaped));
}
GenericValue Value = Unescaped;
return Processor->processValueToken(Value, Token);
}
-GenericValue ParseChar(const Parser::TokenInfo& Token,
+GenericValue parseChar(const Parser::TokenInfo& Token,
Parser::TokenProcessor* Processor) {
if (Token.Token.size() < 3 ||
!Token.Token.startswith("'") || !Token.Token.endswith("'")) {
@@ -163,7 +163,7 @@
llvm::Twine("Error parsing char token: <" + Token.Token + ">").str());
}
llvm::StringRef Escaped = Token.Token.drop_front().drop_back();
- const int Unescaped = UnescapeCharSequence(&Escaped);
+ const int Unescaped = unescapeCharSequence(&Escaped);
if (!Escaped.empty()) {
return GenericError(
llvm::Twine("Error parsing char token: <" + Token.Token + ">").str());
@@ -173,7 +173,7 @@
return Processor->processValueToken(Value, Token);
}
-GenericValue ParseNumber(const Parser::TokenInfo& Token,
+GenericValue parseNumber(const Parser::TokenInfo& Token,
Parser::TokenProcessor* Processor) {
long long SignedLong;
if (!Token.Token.getAsInteger(0, SignedLong)) {
@@ -195,11 +195,11 @@
llvm::Twine("Error parsing number token: <" + Token.Token + ">").str());
}
-GenericValue ParseToken(const Parser::TokenInfo& Token,
+GenericValue parseToken(const Parser::TokenInfo& Token,
CodeTokenizer* Tokenizer,
Parser::TokenProcessor* Processor);
-GenericValue ParseMatcher(const Parser::TokenInfo& Token,
+GenericValue parseMatcher(const Parser::TokenInfo& Token,
CodeTokenizer* Tokenizer,
Parser::TokenProcessor* Processor) {
const Parser::TokenInfo& OpenToken = Tokenizer->getNextToken();
@@ -227,7 +227,7 @@
}
NextToken = Tokenizer->getNextToken();
}
- const GenericValue Arg = ParseToken(NextToken, Tokenizer, Processor);
+ const GenericValue Arg = parseToken(NextToken, Tokenizer, Processor);
if (Arg.is<GenericError>()) {
return GenericError(
llvm::Twine("Error parsing argument " + llvm::Twine(Args.size()) +
@@ -257,18 +257,18 @@
return Result;
}
-GenericValue ParseToken(const Parser::TokenInfo& Token,
+GenericValue parseToken(const Parser::TokenInfo& Token,
CodeTokenizer* Tokenizer,
Parser::TokenProcessor* Processor) {
if (Token.Token.empty()) {
return GenericError("End of code found while looking for token.");
}
- if (Token.Token[0] == '"') return ParseString(Token, Processor);
- if (Token.Token[0] == '\'') return ParseChar(Token, Processor);
+ if (Token.Token[0] == '"') return parseString(Token, Processor);
+ if (Token.Token[0] == '\'') return parseChar(Token, Processor);
if (isdigit(Token.Token[0]) ||
Token.Token[0] == '-' || Token.Token[0] == '+') {
- return ParseNumber(Token, Processor);
+ return parseNumber(Token, Processor);
}
// TODO: Do this better when we have more constants.
@@ -278,7 +278,7 @@
if (Token.Token == "false")
return Processor->processValueToken(false, Token);
- return ParseMatcher(Token, Tokenizer, Processor);
+ return parseMatcher(Token, Tokenizer, Processor);
}
} // anonymous namespace
@@ -286,7 +286,7 @@
GenericValue Parser::parseMatcher(llvm::StringRef Code,
Parser::TokenProcessor* Processor) {
CodeTokenizer Tokenizer(Code);
- return ParseToken(Tokenizer.getNextToken(), &Tokenizer, Processor);
+ return parseToken(Tokenizer.getNextToken(), &Tokenizer, Processor);
}
} // namespace dynamic
Modified: cfe/branches/tooling/lib/ASTMatchers/Dynamic/Registry.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/ASTMatchers/Dynamic/Registry.cpp?rev=159535&r1=159534&r2=159535&view=diff
==============================================================================
--- cfe/branches/tooling/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/branches/tooling/lib/ASTMatchers/Dynamic/Registry.cpp Mon Jul 2 11:15:56 2012
@@ -29,13 +29,13 @@
// defined in the AST.
#define DECL(DERIVED, BASE) \
class DERIVED##Decl; \
-const char* GetRegistryTypeName(DERIVED##Decl* dummy) { return #DERIVED; }
+const char* getRegistryTypeName(DERIVED##Decl* dummy) { return #DERIVED; }
#include "clang/AST/DeclNodes.inc"
#define STMT(CLASS, PARENT) \
class CLASS; \
-const char* GetRegistryTypeName(CLASS* dummy) { return #CLASS; }
+const char* getRegistryTypeName(CLASS* dummy) { return #CLASS; }
#include "clang/AST/StmtNodes.inc"
-const char* GetRegistryTypeName(Stmt* dummy) { return "Stmt"; }
+const char* getRegistryTypeName(Stmt* dummy) { return "Stmt"; }
namespace ast_matchers {
@@ -45,9 +45,9 @@
template <typename P1> \
R name(const P1& t1) { return func(t1); } \
-MAKE_HELPER_POLY_FUNCTION1(HasType, HasType_Expr,
+MAKE_HELPER_POLY_FUNCTION1(hasType, hasType_Expr,
internal::Matcher<clang::Expr>)
-MAKE_HELPER_POLY_FUNCTION1(HasType, HasType_ValueDecl,
+MAKE_HELPER_POLY_FUNCTION1(hasType, hasType_ValueDecl,
internal::Matcher<clang::ValueDecl>)
namespace dynamic {
@@ -96,7 +96,7 @@
const llvm::OwningPtr<const MatcherCreateCallback> Callback2;
};
-void RegisterMatcher(const std::string& MatcherName,
+void registerMatcher(const std::string& MatcherName,
MatcherCreateCallback* Callback,
RegistryMaps* Data) {
const MatcherCreateCallback** MapCallback = &Data->Constructors[MatcherName];
@@ -107,41 +107,41 @@
}
template <typename T>
-void RegisterKindName(const std::string& MatcherName, const T& t,
+void registerKindName(const std::string& MatcherName, const T& t,
RegistryMaps* Data) { }
template <typename Base, typename Type>
-void RegisterKindName(
+void registerKindName(
const std::string& MatcherName,
ast_matchers::internal::VariadicDynCastAllOfMatcher<Base, Type> Func,
RegistryMaps* Data) {
- Data->KindNames[GetRegistryTypeName(static_cast<Type*>(NULL))] = MatcherName;
+ Data->KindNames[getRegistryTypeName(static_cast<Type*>(NULL))] = MatcherName;
Data->AllKinds.insert(MatcherName);
}
#define MATCH_NS ::clang::ast_matchers
#define REGISTER_NAMED_MATCHER_AUTO(name, func) \
- RegisterMatcher(#name, \
- internal::MakeMatcherAutoMarshall(MATCH_NS::func, #name), \
+ registerMatcher(#name, \
+ internal::makeMatcherAutoMarshall(MATCH_NS::func, #name), \
Data)
#define REGISTER_MATCHER_AUTO(name) \
REGISTER_NAMED_MATCHER_AUTO(name, name); \
- RegisterKindName(#name, MATCH_NS::name, Data)
+ registerKindName(#name, MATCH_NS::name, Data)
#define REGISTER_POLY_NAMED_MATCHER_AUTO(name, func, R) \
- RegisterMatcher(#name, \
- internal::MakeMatcherAutoMarshallPoly<Matcher<R> >( \
+ registerMatcher(#name, \
+ internal::makeMatcherAutoMarshallPoly<Matcher<R> >( \
MATCH_NS::func, #name), Data)
#define REGISTER_POLY_MATCHER_AUTO(name, R) \
REGISTER_POLY_NAMED_MATCHER_AUTO(name, name, R)
#define REGISTER_MATCHER1(name, R, P1) \
- RegisterMatcher(#name, internal::MakeMatcherAutoMarshallPoly<R, R, P1>( \
+ registerMatcher(#name, internal::makeMatcherAutoMarshallPoly<R, R, P1>( \
MATCH_NS::name, #name), Data)
-RegistryMaps* RegisterMatchers() {
+RegistryMaps* registerMatchers() {
RegistryMaps* Data = new RegistryMaps();
REGISTER_MATCHER_AUTO(BinaryOperator);
@@ -164,115 +164,115 @@
REGISTER_MATCHER_AUTO(Expression);
REGISTER_MATCHER_AUTO(Field);
REGISTER_MATCHER_AUTO(For);
- REGISTER_MATCHER_AUTO(ForField);
+ REGISTER_MATCHER_AUTO(forField);
REGISTER_MATCHER_AUTO(Function);
REGISTER_MATCHER_AUTO(FunctionalCast);
- REGISTER_MATCHER_AUTO(HasAnyConstructorInitializer);
- REGISTER_MATCHER_AUTO(HasAnyConstructorInitializer);
- REGISTER_MATCHER_AUTO(HasAnyParameter);
- REGISTER_MATCHER_AUTO(HasAnySubstatement);
- REGISTER_MATCHER_AUTO(HasBody);
- REGISTER_MATCHER_AUTO(HasConditionVariableStatement);
- REGISTER_MATCHER_AUTO(HasDestinationType);
- REGISTER_MATCHER_AUTO(HasEitherOperand);
- REGISTER_MATCHER_AUTO(HasFalseExpression);
- REGISTER_MATCHER_AUTO(HasImplicitDestinationType);
- REGISTER_MATCHER_AUTO(HasInitializer);
- REGISTER_MATCHER_AUTO(HasLHS);
- REGISTER_MATCHER_AUTO(HasName);
- REGISTER_MATCHER_AUTO(HasObjectExpression);
- REGISTER_MATCHER_AUTO(HasOverloadedOperatorName);
- REGISTER_MATCHER_AUTO(HasParameter);
- REGISTER_MATCHER_AUTO(HasRHS);
- REGISTER_MATCHER_AUTO(HasSourceExpression);
- REGISTER_MATCHER_AUTO(HasTrueExpression);
- REGISTER_MATCHER_AUTO(HasUnaryOperand);
+ REGISTER_MATCHER_AUTO(hasAnyConstructorInitializer);
+ REGISTER_MATCHER_AUTO(hasAnyConstructorInitializer);
+ REGISTER_MATCHER_AUTO(hasAnyParameter);
+ REGISTER_MATCHER_AUTO(hasAnySubstatement);
+ REGISTER_MATCHER_AUTO(hasBody);
+ REGISTER_MATCHER_AUTO(hasConditionVariableStatement);
+ REGISTER_MATCHER_AUTO(hasDestinationType);
+ REGISTER_MATCHER_AUTO(hasEitherOperand);
+ REGISTER_MATCHER_AUTO(hasFalseExpression);
+ REGISTER_MATCHER_AUTO(hasImplicitDestinationType);
+ REGISTER_MATCHER_AUTO(hasInitializer);
+ REGISTER_MATCHER_AUTO(hasLHS);
+ REGISTER_MATCHER_AUTO(hasName);
+ REGISTER_MATCHER_AUTO(hasObjectExpression);
+ REGISTER_MATCHER_AUTO(hasOverloadedOperatorName);
+ REGISTER_MATCHER_AUTO(hasParameter);
+ REGISTER_MATCHER_AUTO(hasRHS);
+ REGISTER_MATCHER_AUTO(hasSourceExpression);
+ REGISTER_MATCHER_AUTO(hasTrueExpression);
+ REGISTER_MATCHER_AUTO(hasUnaryOperand);
REGISTER_MATCHER_AUTO(If);
REGISTER_MATCHER_AUTO(ImplicitCast);
REGISTER_MATCHER_AUTO(IntegerLiteral);
- REGISTER_MATCHER_AUTO(IsArrow);
- REGISTER_MATCHER_AUTO(IsConstQualified);
- REGISTER_MATCHER_AUTO(IsDerivedFrom);
- REGISTER_MATCHER_AUTO(IsImplicit);
- REGISTER_MATCHER_AUTO(IsWritten);
- REGISTER_MATCHER_AUTO(Member);
+ REGISTER_MATCHER_AUTO(isArrow);
+ REGISTER_MATCHER_AUTO(isConstQualified);
+ REGISTER_MATCHER_AUTO(isDerivedFrom);
+ REGISTER_MATCHER_AUTO(isImplicit);
+ REGISTER_MATCHER_AUTO(isWritten);
+ REGISTER_MATCHER_AUTO(member);
REGISTER_MATCHER_AUTO(MemberExpression);
REGISTER_MATCHER_AUTO(Method);
REGISTER_MATCHER_AUTO(NameableDeclaration);
REGISTER_MATCHER_AUTO(NewExpression);
- REGISTER_MATCHER_AUTO(OfClass);
- REGISTER_MATCHER_AUTO(On);
- REGISTER_MATCHER_AUTO(OnImplicitObjectArgument);
+ REGISTER_MATCHER_AUTO(ofClass);
+ REGISTER_MATCHER_AUTO(on);
+ REGISTER_MATCHER_AUTO(onImplicitObjectArgument);
REGISTER_MATCHER_AUTO(OverloadedOperatorCall);
REGISTER_MATCHER_AUTO(ReinterpretCast);
REGISTER_MATCHER_AUTO(Statement);
- REGISTER_MATCHER_AUTO(StatementCountIs);
+ REGISTER_MATCHER_AUTO(statementCountIs);
REGISTER_MATCHER_AUTO(StaticCast);
REGISTER_MATCHER_AUTO(StringLiteral);
REGISTER_MATCHER_AUTO(SwitchCase);
- REGISTER_MATCHER_AUTO(To);
+ REGISTER_MATCHER_AUTO(to);
REGISTER_MATCHER_AUTO(UnaryOperator);
REGISTER_MATCHER_AUTO(Variable);
REGISTER_MATCHER_AUTO(While);
- REGISTER_MATCHER_AUTO(WithInitializer);
+ REGISTER_MATCHER_AUTO(withInitializer);
// HasType is very special. It is overloaded on parameter and return value.
- REGISTER_NAMED_MATCHER_AUTO(HasType, HasType_Expr<Matcher<clang::QualType> >);
- REGISTER_NAMED_MATCHER_AUTO(HasType, HasType_Expr<Matcher<clang::Decl> >);
+ REGISTER_NAMED_MATCHER_AUTO(HasType, hasType_Expr<Matcher<clang::QualType> >);
+ REGISTER_NAMED_MATCHER_AUTO(HasType, hasType_Expr<Matcher<clang::Decl> >);
REGISTER_NAMED_MATCHER_AUTO(HasType,
- HasType_ValueDecl<Matcher<clang::QualType> >);
+ hasType_ValueDecl<Matcher<clang::QualType> >);
REGISTER_NAMED_MATCHER_AUTO(HasType,
- HasType_ValueDecl<Matcher<clang::Decl> >);
+ hasType_ValueDecl<Matcher<clang::Decl> >);
// True
- REGISTER_POLY_MATCHER_AUTO(True, clang::Stmt);
- REGISTER_POLY_MATCHER_AUTO(True, clang::QualType);
- REGISTER_POLY_MATCHER_AUTO(True, clang::Decl);
- REGISTER_POLY_MATCHER_AUTO(True, clang::CXXCtorInitializer);
+ REGISTER_POLY_MATCHER_AUTO(anything, clang::Stmt);
+ REGISTER_POLY_MATCHER_AUTO(anything, clang::QualType);
+ REGISTER_POLY_MATCHER_AUTO(anything, clang::Decl);
+ REGISTER_POLY_MATCHER_AUTO(anything, clang::CXXCtorInitializer);
// HasAnyArgument
- REGISTER_POLY_MATCHER_AUTO(HasAnyArgument, clang::CallExpr);
- REGISTER_POLY_MATCHER_AUTO(HasAnyArgument, clang::CXXConstructExpr);
+ REGISTER_POLY_MATCHER_AUTO(hasAnyArgument, clang::CallExpr);
+ REGISTER_POLY_MATCHER_AUTO(hasAnyArgument, clang::CXXConstructExpr);
// HasDeclaration
- REGISTER_POLY_MATCHER_AUTO(HasDeclaration, clang::QualType);
- REGISTER_POLY_MATCHER_AUTO(HasDeclaration, clang::CallExpr);
- REGISTER_POLY_MATCHER_AUTO(HasDeclaration, clang::CXXConstructExpr);
+ REGISTER_POLY_MATCHER_AUTO(hasDeclaration, clang::QualType);
+ REGISTER_POLY_MATCHER_AUTO(hasDeclaration, clang::CallExpr);
+ REGISTER_POLY_MATCHER_AUTO(hasDeclaration, clang::CXXConstructExpr);
// HasArgument
- REGISTER_POLY_MATCHER_AUTO(HasArgument, clang::CallExpr);
- REGISTER_POLY_MATCHER_AUTO(HasArgument, clang::CXXConstructExpr);
+ REGISTER_POLY_MATCHER_AUTO(hasArgument, clang::CallExpr);
+ REGISTER_POLY_MATCHER_AUTO(hasArgument, clang::CXXConstructExpr);
// HasOperatorName
- REGISTER_POLY_MATCHER_AUTO(HasOperatorName, clang::BinaryOperator);
- REGISTER_POLY_MATCHER_AUTO(HasOperatorName, clang::UnaryOperator);
+ REGISTER_POLY_MATCHER_AUTO(hasOperatorName, clang::BinaryOperator);
+ REGISTER_POLY_MATCHER_AUTO(hasOperatorName, clang::UnaryOperator);
// IsDefinition
- REGISTER_POLY_MATCHER_AUTO(IsDefinition, clang::TagDecl);
- REGISTER_POLY_MATCHER_AUTO(IsDefinition, clang::VarDecl);
- REGISTER_POLY_MATCHER_AUTO(IsDefinition, clang::FunctionDecl);
+ REGISTER_POLY_MATCHER_AUTO(isDefinition, clang::TagDecl);
+ REGISTER_POLY_MATCHER_AUTO(isDefinition, clang::VarDecl);
+ REGISTER_POLY_MATCHER_AUTO(isDefinition, clang::FunctionDecl);
// IsTemplateInstantiation
- REGISTER_POLY_MATCHER_AUTO(IsTemplateInstantiation, clang::FunctionDecl);
- REGISTER_POLY_MATCHER_AUTO(IsTemplateInstantiation, clang::VarDecl);
- REGISTER_POLY_MATCHER_AUTO(IsTemplateInstantiation, clang::CXXRecordDecl);
+ REGISTER_POLY_MATCHER_AUTO(isTemplateInstantiation, clang::FunctionDecl);
+ REGISTER_POLY_MATCHER_AUTO(isTemplateInstantiation, clang::VarDecl);
+ REGISTER_POLY_MATCHER_AUTO(isTemplateInstantiation, clang::CXXRecordDecl);
// ArgumentCountIs
- REGISTER_POLY_MATCHER_AUTO(ArgumentCountIs, clang::CallExpr);
- REGISTER_POLY_MATCHER_AUTO(ArgumentCountIs, clang::CXXConstructExpr);
+ REGISTER_POLY_MATCHER_AUTO(argumentCountIs, clang::CallExpr);
+ REGISTER_POLY_MATCHER_AUTO(argumentCountIs, clang::CXXConstructExpr);
// For if() and (?:)
- REGISTER_POLY_MATCHER_AUTO(HasCondition, clang::IfStmt);
- REGISTER_POLY_MATCHER_AUTO(HasCondition, clang::ConditionalOperator);
+ REGISTER_POLY_MATCHER_AUTO(hasCondition, clang::IfStmt);
+ REGISTER_POLY_MATCHER_AUTO(hasCondition, clang::ConditionalOperator);
// Equals. TODO: Needs more.
- REGISTER_POLY_NAMED_MATCHER_AUTO(Equals, Equals<bool>,
+ REGISTER_POLY_NAMED_MATCHER_AUTO(Equals, equals<bool>,
clang::CXXBoolLiteralExpr);
- REGISTER_POLY_NAMED_MATCHER_AUTO(Equals, Equals<unsigned long long>,
+ REGISTER_POLY_NAMED_MATCHER_AUTO(Equals, equals<unsigned long long>,
clang::IntegerLiteral);
- REGISTER_POLY_NAMED_MATCHER_AUTO(Equals, Equals<long long>,
+ REGISTER_POLY_NAMED_MATCHER_AUTO(Equals, equals<long long>,
clang::IntegerLiteral);
- REGISTER_POLY_NAMED_MATCHER_AUTO(Equals, Equals<unsigned>,
+ REGISTER_POLY_NAMED_MATCHER_AUTO(Equals, equals<unsigned>,
clang::CharacterLiteral);
// Has/hasDescendant/forEach/forEachDescendant for Decl and Stmt
@@ -291,53 +291,53 @@
// Id
- REGISTER_NAMED_MATCHER_AUTO(Id, Id<clang::Decl>);
- REGISTER_NAMED_MATCHER_AUTO(Id, Id<clang::Stmt>);
+ REGISTER_NAMED_MATCHER_AUTO(Id, id<clang::Decl>);
+ REGISTER_NAMED_MATCHER_AUTO(Id, id<clang::Stmt>);
// Not. One per basic type.
- REGISTER_POLY_NAMED_MATCHER_AUTO(Not, Not<Matcher<clang::Decl> >,
+ REGISTER_POLY_NAMED_MATCHER_AUTO(Not, unless<Matcher<clang::Decl> >,
clang::Decl);
- REGISTER_POLY_NAMED_MATCHER_AUTO(Not, Not<Matcher<clang::Stmt> >,
+ REGISTER_POLY_NAMED_MATCHER_AUTO(Not, unless<Matcher<clang::Stmt> >,
clang::Stmt);
- REGISTER_POLY_NAMED_MATCHER_AUTO(Not, Not<Matcher<clang::QualType> >,
+ REGISTER_POLY_NAMED_MATCHER_AUTO(Not, unless<Matcher<clang::QualType> >,
clang::QualType);
REGISTER_POLY_NAMED_MATCHER_AUTO(Not,
- Not<Matcher<clang::CXXCtorInitializer> >,
+ unless<Matcher<clang::CXXCtorInitializer> >,
clang::CXXCtorInitializer);
// ThisPointerType is overloaded.
- REGISTER_MATCHER1(ThisPointerType, Matcher<clang::CallExpr>,
+ REGISTER_MATCHER1(thisPointerType, Matcher<clang::CallExpr>,
const Matcher<clang::QualType>&);
- REGISTER_MATCHER1(ThisPointerType, Matcher<clang::CallExpr>,
+ REGISTER_MATCHER1(thisPointerType, Matcher<clang::CallExpr>,
const Matcher<clang::Decl>&);
// Callee is overloaded.
- REGISTER_MATCHER1(Callee, Matcher<clang::CallExpr>,
+ REGISTER_MATCHER1(callee, Matcher<clang::CallExpr>,
const Matcher<clang::Stmt>&);
- REGISTER_MATCHER1(Callee, Matcher<clang::CallExpr>,
+ REGISTER_MATCHER1(callee, Matcher<clang::CallExpr>,
const Matcher<clang::Decl>&);
// PointsTo is overloaded.
- REGISTER_MATCHER1(PointsTo, Matcher<clang::QualType>,
+ REGISTER_MATCHER1(pointsTo, Matcher<clang::QualType>,
const Matcher<clang::QualType>&);
- REGISTER_MATCHER1(PointsTo, Matcher<clang::QualType>,
+ REGISTER_MATCHER1(pointsTo, Matcher<clang::QualType>,
const Matcher<clang::Decl>&);
// References is overloaded.
- REGISTER_MATCHER1(References, Matcher<clang::QualType>,
+ REGISTER_MATCHER1(references, Matcher<clang::QualType>,
const Matcher<clang::QualType>&);
- REGISTER_MATCHER1(References, Matcher<clang::QualType>,
+ REGISTER_MATCHER1(references, Matcher<clang::QualType>,
const Matcher<clang::Decl>&);
// Some hardcoded marshallers
- RegisterMatcher("allOf", new internal::MatcherMarshallAllOf, Data);
- RegisterMatcher("anyOf", new internal::MatcherMarshallAnyOf, Data);
+ registerMatcher("allOf", new internal::MatcherMarshallAllOf, Data);
+ registerMatcher("anyOf", new internal::MatcherMarshallAnyOf, Data);
return Data;
}
// The registry is const to make it thread-safe.
-static const RegistryMaps* const RegistryData = RegisterMatchers();
+static const RegistryMaps* const RegistryData = registerMatchers();
} // anonymous namespace
Modified: cfe/branches/tooling/tools/fix-llvm-style/FixLLVMStyle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/fix-llvm-style/FixLLVMStyle.cpp?rev=159535&r1=159534&r2=159535&view=diff
==============================================================================
--- cfe/branches/tooling/tools/fix-llvm-style/FixLLVMStyle.cpp (original)
+++ cfe/branches/tooling/tools/fix-llvm-style/FixLLVMStyle.cpp Mon Jul 2 11:15:56 2012
@@ -150,6 +150,8 @@
if (isupper(Name[0])) {
Name[0] = tolower(Name[0]);
if (Name == "new") Name = "create";
+ if (Name == "true") Name = "anything";
+ if (Name == "not") Name = "unless";
if (const DeclRefExpr *Reference = Result.Nodes.getStmtAs<DeclRefExpr>("ref")) {
ReplaceText = Replacement(*Result.SourceManager, CharSourceRange::getTokenRange(SourceRange(Reference->getLocation(), Reference->getLocation())), Name);
@@ -184,14 +186,14 @@
}
}
}
- if (EditFilesExpression.match(ReplaceText.getFilePath())) {
+ //if (EditFilesExpression.match(ReplaceText.getFilePath())) {
//llvm::errs() << GetPosition(*Result.Nodes.GetDeclAs<NamedDecl>("declaration"), *Result.SourceManager) << "\n";
//llvm::errs
llvm::outs() << ReplaceText.getFilePath() << ":" << ReplaceText.getOffset() << ", " << ReplaceText.getLength() << ": s/" << OldName << "/" << Name << "/g;\n";
Replace->insert(ReplaceText);
- } else {
+ //} else {
// llvm::errs() << ReplaceText.GetFilePath() << ":" << ReplaceText.GetOffset() << ", " << ReplaceText.GetLength() << ": s/" << OldName << "/" << Name << "/g;\n";
- }
+ //}
}
private:
@@ -202,7 +204,7 @@
const internal::VariadicDynCastAllOfMatcher<clang::Decl, clang::UsingDecl> UsingDeclaration;
namespace clang { namespace ast_matchers {
-AST_MATCHER_P(clang::UsingDecl, HasAnyUsingShadowDeclaration,
+AST_MATCHER_P(clang::UsingDecl, hasAnyUsingShadowDeclaration,
internal::Matcher<clang::UsingShadowDecl>, InnerMatcher) {
for (clang::UsingDecl::shadow_iterator I = Node.shadow_begin();
I != Node.shadow_end(); ++I) {
@@ -212,11 +214,11 @@
}
return false;
}
-AST_MATCHER_P(clang::UsingShadowDecl, HasTargetDeclaration,
+AST_MATCHER_P(clang::UsingShadowDecl, hasTargetDeclaration,
internal::Matcher<clang::NamedDecl>, InnerMatcher) {
return InnerMatcher.matches(*Node.getTargetDecl(), Finder, Builder);
}
-AST_MATCHER_P(clang::QualType, HasClassDeclaration,
+AST_MATCHER_P(clang::QualType, hasClassDeclaration,
internal::Matcher<clang::CXXRecordDecl>, InnerMatcher) {
if (const clang::CXXRecordDecl *Decl = Node->getAsCXXRecordDecl()) {
return InnerMatcher.matches(*Decl, Finder, Builder);
@@ -230,7 +232,7 @@
}
return false;
}
-AST_MATCHER_P(clang::FunctionDecl, HasReturnType,
+AST_MATCHER_P(clang::FunctionDecl, hasReturnType,
internal::Matcher<clang::QualType>, InnerMatcher) {
llvm::errs() << Node.getNameAsString() << "\n";
Node.getResultType().dump();
@@ -252,7 +254,7 @@
}
return InnerMatcher.matches(Node.getResultType(), Finder, Builder);
}
-AST_MATCHER_P(clang::NamedDecl, HasName2, std::string, name) {
+AST_MATCHER_P(clang::NamedDecl, hasName2, std::string, name) {
assert(!name.empty());
const std::string full_name_string = "::" + Node.getQualifiedNameAsString();
const llvm::StringRef full_name = full_name_string;
@@ -287,18 +289,18 @@
ast_matchers::MatchFinder Finder;
FixLLVMStyle Callback(&Tool.getReplacements());
- Finder.addMatcher(StatementMatcher(AnyOf(
- StatementMatcher(Id("ref", DeclarationReference(To(Id("declaration", Function()))))),
- Call(Callee(Id("declaration", Function())),
- Callee(Id("callee", Expression()))))),
+ Finder.addMatcher(StatementMatcher(anyOf(
+ StatementMatcher(id("ref", DeclarationReference(to(id("declaration", Function()))))),
+ Call(callee(id("declaration", Function())),
+ callee(id("callee", Expression()))))),
&Callback);
Finder.addMatcher(
- DeclarationMatcher(AnyOf(
- Id("declaration", UsingDeclaration(HasAnyUsingShadowDeclaration(HasTargetDeclaration(Function())))),
- AllOf(
- Id("declaration", Function()),
- Not(Constructor())))
+ DeclarationMatcher(anyOf(
+ id("declaration", UsingDeclaration(hasAnyUsingShadowDeclaration(hasTargetDeclaration(Function())))),
+ allOf(
+ id("declaration", Function()),
+ unless(Constructor())))
),
&Callback);
return Tool.run(newFrontendActionFactory(&Finder));
Modified: cfe/branches/tooling/tools/remove-cstr-calls/RemoveCStrCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/remove-cstr-calls/RemoveCStrCalls.cpp?rev=159535&r1=159534&r2=159535&view=diff
==============================================================================
--- cfe/branches/tooling/tools/remove-cstr-calls/RemoveCStrCalls.cpp (original)
+++ cfe/branches/tooling/tools/remove-cstr-calls/RemoveCStrCalls.cpp Mon Jul 2 11:15:56 2012
@@ -188,21 +188,21 @@
FixCStrCall Callback(&Tool.getReplacements());
Finder.addMatcher(
ConstructorCall(
- HasDeclaration(Method(HasName(StringConstructor))),
- ArgumentCountIs(2),
+ hasDeclaration(Method(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(
+ hasArgument(
0,
- Id("call", Call(
- Callee(Id("member", MemberExpression())),
- Callee(Method(HasName(StringCStrMethod))),
- On(Id("arg", Expression()))))),
+ id("call", Call(
+ callee(id("member", MemberExpression())),
+ callee(Method(hasName(StringCStrMethod))),
+ on(id("arg", Expression()))))),
// The second argument is the alloc object which must not be
// present explicitly.
- HasArgument(
+ hasArgument(
1,
DefaultArgument())),
&Callback);
@@ -212,21 +212,21 @@
// 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(Method(AnyOf(
- HasName("::llvm::StringRef::StringRef"),
- HasName("::llvm::Twine::Twine")))),
- ArgumentCountIs(1),
+ hasDeclaration(Method(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(
+ hasArgument(
0,
- Id("call", Call(
- Callee(Id("member", MemberExpression())),
- Callee(Method(HasName(StringCStrMethod))),
- On(Id("arg", Expression())))))),
+ id("call", Call(
+ callee(id("member", MemberExpression())),
+ callee(Method(hasName(StringCStrMethod))),
+ on(id("arg", Expression())))))),
&Callback);
return Tool.run(newFrontendActionFactory(&Finder));
}
Modified: cfe/branches/tooling/unittests/ASTMatchers/ASTMatchersTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=159535&r1=159534&r2=159535&view=diff
==============================================================================
--- cfe/branches/tooling/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
+++ cfe/branches/tooling/unittests/ASTMatchers/ASTMatchersTest.cpp Mon Jul 2 11:15:56 2012
@@ -18,20 +18,20 @@
TEST(HasNameDeathTest, DiesOnEmptyName) {
ASSERT_DEBUG_DEATH({
- DeclarationMatcher HasEmptyName = Class(HasName(""));
+ DeclarationMatcher HasEmptyName = Class(hasName(""));
EXPECT_TRUE(notMatches("class X {};", HasEmptyName));
}, "");
}
TEST(IsDerivedFromDeathTest, DiesOnEmptyBaseName) {
ASSERT_DEBUG_DEATH({
- DeclarationMatcher IsDerivedFromEmpty = Class(IsDerivedFrom(""));
+ DeclarationMatcher IsDerivedFromEmpty = Class(isDerivedFrom(""));
EXPECT_TRUE(notMatches("class X {};", IsDerivedFromEmpty));
}, "");
}
TEST(NameableDeclaration, MatchesVariousDecls) {
- DeclarationMatcher NamedX = NameableDeclaration(HasName("X"));
+ DeclarationMatcher NamedX = NameableDeclaration(hasName("X"));
EXPECT_TRUE(matches("typedef int X;", NamedX));
EXPECT_TRUE(matches("int X;", NamedX));
EXPECT_TRUE(matches("class foo { virtual void X(); };", NamedX));
@@ -46,7 +46,7 @@
DeclarationMatcher ClassMatcher(Class());
EXPECT_FALSE(matches("", ClassMatcher));
- DeclarationMatcher ClassX = Class(Class(HasName("X")));
+ DeclarationMatcher ClassX = Class(Class(hasName("X")));
EXPECT_TRUE(matches("class X;", ClassX));
EXPECT_TRUE(matches("class X {};", ClassX));
EXPECT_TRUE(matches("template<class T> class X {};", ClassX));
@@ -54,7 +54,7 @@
}
TEST(DeclarationMatcher, ClassIsDerived) {
- DeclarationMatcher IsDerivedFromX = Class(IsDerivedFrom("X"));
+ DeclarationMatcher IsDerivedFromX = Class(isDerivedFrom("X"));
EXPECT_TRUE(matches("class X {}; class Y : public X {};", IsDerivedFromX));
EXPECT_TRUE(matches("class X {}; class Y : public X {};", IsDerivedFromX));
@@ -64,7 +64,7 @@
EXPECT_TRUE(notMatches("", IsDerivedFromX));
DeclarationMatcher ZIsDerivedFromX =
- Class(HasName("Z"), IsDerivedFrom("X"));
+ Class(hasName("Z"), isDerivedFrom("X"));
EXPECT_TRUE(
matches("class X {}; class Y : public X {}; class Z : public Y {};",
ZIsDerivedFromX));
@@ -195,19 +195,19 @@
"void f() { Z<float> z_float; Z<double> z_double; Z<char> z_char; }";
EXPECT_TRUE(matches(
RecursiveTemplateOneParameter,
- Variable(HasName("z_float"),
- HasInitializer(HasType(Class(IsDerivedFrom("Base1")))))));
+ Variable(hasName("z_float"),
+ hasInitializer(hasType(Class(isDerivedFrom("Base1")))))));
EXPECT_TRUE(notMatches(
RecursiveTemplateOneParameter,
Variable(
- HasName("z_float"),
- HasInitializer(HasType(Class(IsDerivedFrom("Base2")))))));
+ hasName("z_float"),
+ hasInitializer(hasType(Class(isDerivedFrom("Base2")))))));
EXPECT_TRUE(matches(
RecursiveTemplateOneParameter,
Variable(
- HasName("z_char"),
- HasInitializer(HasType(Class(IsDerivedFrom("Base1"),
- IsDerivedFrom("Base2")))))));
+ hasName("z_char"),
+ hasInitializer(hasType(Class(isDerivedFrom("Base1"),
+ isDerivedFrom("Base2")))))));
const char *RecursiveTemplateTwoParameters =
"class Base1 {}; class Base2 {};"
@@ -223,24 +223,24 @@
EXPECT_TRUE(matches(
RecursiveTemplateTwoParameters,
Variable(
- HasName("z_float"),
- HasInitializer(HasType(Class(IsDerivedFrom("Base1")))))));
+ hasName("z_float"),
+ hasInitializer(hasType(Class(isDerivedFrom("Base1")))))));
EXPECT_TRUE(notMatches(
RecursiveTemplateTwoParameters,
Variable(
- HasName("z_float"),
- HasInitializer(HasType(Class(IsDerivedFrom("Base2")))))));
+ hasName("z_float"),
+ hasInitializer(hasType(Class(isDerivedFrom("Base2")))))));
EXPECT_TRUE(matches(
RecursiveTemplateTwoParameters,
Variable(
- HasName("z_char"),
- HasInitializer(HasType(Class(IsDerivedFrom("Base1"),
- IsDerivedFrom("Base2")))))));
+ hasName("z_char"),
+ hasInitializer(hasType(Class(isDerivedFrom("Base1"),
+ isDerivedFrom("Base2")))))));
}
TEST(DeclarationMatcher, MatchAnyOf) {
DeclarationMatcher YOrZDerivedFromX =
- Class(AnyOf(HasName("Y"), AllOf(IsDerivedFrom("X"), HasName("Z"))));
+ Class(anyOf(hasName("Y"), allOf(isDerivedFrom("X"), hasName("Z"))));
EXPECT_TRUE(
matches("class X {}; class Z : public X {};", YOrZDerivedFromX));
@@ -250,8 +250,8 @@
EXPECT_TRUE(notMatches("class Z {};", YOrZDerivedFromX));
DeclarationMatcher XOrYOrZOrUOrV =
- Class(AnyOf(HasName("X"), HasName("Y"), HasName("Z"), HasName("U"),
- HasName("V")));
+ Class(anyOf(hasName("X"), hasName("Y"), hasName("Z"), hasName("U"),
+ hasName("V")));
EXPECT_TRUE(matches("class X {};", XOrYOrZOrUOrV));
EXPECT_TRUE(matches("class Y {};", XOrYOrZOrUOrV));
@@ -262,13 +262,13 @@
}
TEST(DeclarationMatcher, MatchHas) {
- DeclarationMatcher HasClassX = Class(has(Class(HasName("X"))));
+ DeclarationMatcher HasClassX = Class(has(Class(hasName("X"))));
EXPECT_TRUE(matches("class Y { class X {}; };", HasClassX));
EXPECT_TRUE(matches("class X {};", HasClassX));
DeclarationMatcher YHasClassX =
- Class(HasName("Y"), has(Class(HasName("X"))));
+ Class(hasName("Y"), has(Class(hasName("X"))));
EXPECT_TRUE(matches("class Y { class X {}; };", YHasClassX));
EXPECT_TRUE(notMatches("class X {};", YHasClassX));
EXPECT_TRUE(
@@ -279,14 +279,14 @@
DeclarationMatcher Recursive =
Class(
has(Class(
- has(Class(HasName("X"))),
- has(Class(HasName("Y"))),
- HasName("Z"))),
+ has(Class(hasName("X"))),
+ has(Class(hasName("Y"))),
+ hasName("Z"))),
has(Class(
- has(Class(HasName("A"))),
- has(Class(HasName("B"))),
- HasName("C"))),
- HasName("F"));
+ has(Class(hasName("A"))),
+ has(Class(hasName("B"))),
+ hasName("C"))),
+ hasName("F"));
EXPECT_TRUE(matches(
"class F {"
@@ -336,22 +336,22 @@
TEST(DeclarationMatcher, MatchHasRecursiveAnyOf) {
DeclarationMatcher Recursive =
Class(
- AnyOf(
+ anyOf(
has(Class(
- AnyOf(
+ anyOf(
has(Class(
- HasName("X"))),
+ hasName("X"))),
has(Class(
- HasName("Y"))),
- HasName("Z")))),
+ hasName("Y"))),
+ hasName("Z")))),
has(Class(
- AnyOf(
- HasName("C"),
+ anyOf(
+ hasName("C"),
has(Class(
- HasName("A"))),
+ hasName("A"))),
has(Class(
- HasName("B")))))),
- HasName("F")));
+ hasName("B")))))),
+ hasName("F")));
EXPECT_TRUE(matches("class F {};", Recursive));
EXPECT_TRUE(matches("class Z {};", Recursive));
@@ -367,9 +367,9 @@
TEST(DeclarationMatcher, MatchNot) {
DeclarationMatcher NotClassX =
Class(
- IsDerivedFrom("Y"),
- Not(HasName("Y")),
- Not(HasName("X")));
+ isDerivedFrom("Y"),
+ unless(hasName("Y")),
+ unless(hasName("X")));
EXPECT_TRUE(notMatches("", NotClassX));
EXPECT_TRUE(notMatches("class Y {};", NotClassX));
EXPECT_TRUE(matches("class Y {}; class Z : public Y {};", NotClassX));
@@ -380,10 +380,10 @@
DeclarationMatcher ClassXHasNotClassY =
Class(
- HasName("X"),
- has(Class(HasName("Z"))),
- Not(
- has(Class(HasName("Y")))));
+ hasName("X"),
+ has(Class(hasName("Z"))),
+ unless(
+ has(Class(hasName("Y")))));
EXPECT_TRUE(matches("class X { class Z {}; };", ClassXHasNotClassY));
EXPECT_TRUE(notMatches("class X { class Y {}; class Z {}; };",
ClassXHasNotClassY));
@@ -392,8 +392,8 @@
TEST(DeclarationMatcher, HasDescendant) {
DeclarationMatcher ZDescendantClassX =
Class(
- hasDescendant(Class(HasName("X"))),
- HasName("Z"));
+ hasDescendant(Class(hasName("X"))),
+ hasName("Z"));
EXPECT_TRUE(matches("class Z { class X {}; };", ZDescendantClassX));
EXPECT_TRUE(
matches("class Z { class Y { class X {}; }; };", ZDescendantClassX));
@@ -407,9 +407,9 @@
DeclarationMatcher ZDescendantClassXHasClassY =
Class(
- hasDescendant(Class(has(Class(HasName("Y"))),
- HasName("X"))),
- HasName("Z"));
+ hasDescendant(Class(has(Class(hasName("Y"))),
+ hasName("X"))),
+ hasName("Z"));
EXPECT_TRUE(matches("class Z { class X { class Y {}; }; };",
ZDescendantClassXHasClassY));
EXPECT_TRUE(
@@ -430,9 +430,9 @@
DeclarationMatcher ZDescendantClassXDescendantClassY =
Class(
- hasDescendant(Class(hasDescendant(Class(HasName("Y"))),
- HasName("X"))),
- HasName("Z"));
+ hasDescendant(Class(hasDescendant(Class(hasName("Y"))),
+ hasName("X"))),
+ hasName("Z"));
EXPECT_TRUE(
matches("class Z { class A { class X { class B { class Y {}; }; }; }; };",
ZDescendantClassXDescendantClassY));
@@ -452,8 +452,8 @@
TEST(StatementMatcher, Has) {
StatementMatcher HasVariableI =
Expression(
- HasType(PointsTo(Class(HasName("X")))),
- has(DeclarationReference(To(Variable(HasName("i"))))));
+ hasType(pointsTo(Class(hasName("X")))),
+ has(DeclarationReference(to(Variable(hasName("i"))))));
EXPECT_TRUE(matches(
"class X; X *x(int); void c() { int i; x(i); }", HasVariableI));
@@ -464,8 +464,8 @@
TEST(StatementMatcher, HasDescendant) {
StatementMatcher HasDescendantVariableI =
Expression(
- HasType(PointsTo(Class(HasName("X")))),
- hasDescendant(DeclarationReference(To(Variable(HasName("i"))))));
+ hasType(pointsTo(Class(hasName("X")))),
+ hasDescendant(DeclarationReference(to(Variable(hasName("i"))))));
EXPECT_TRUE(matches(
"class X; X *x(bool); bool b(int); void c() { int i; x(b(i)); }",
@@ -476,19 +476,19 @@
}
TEST(TypeMatcher, MatchesClassType) {
- TypeMatcher TypeA = HasDeclaration(Class(HasName("A")));
+ TypeMatcher TypeA = hasDeclaration(Class(hasName("A")));
EXPECT_TRUE(matches("class A { public: A *a; };", TypeA));
EXPECT_TRUE(notMatches("class A {};", TypeA));
- TypeMatcher TypeDerivedFromA = HasDeclaration(Class(IsDerivedFrom("A")));
+ TypeMatcher TypeDerivedFromA = hasDeclaration(Class(isDerivedFrom("A")));
EXPECT_TRUE(matches("class A {}; class B : public A { public: B *b; };",
TypeDerivedFromA));
EXPECT_TRUE(notMatches("class A {};", TypeA));
- TypeMatcher TypeAHasClassB = HasDeclaration(
- Class(HasName("A"), has(Class(HasName("B")))));
+ TypeMatcher TypeAHasClassB = hasDeclaration(
+ Class(hasName("A"), has(Class(hasName("B")))));
EXPECT_TRUE(
matches("class A { public: A *a; class B {}; };", TypeAHasClassB));
@@ -542,7 +542,7 @@
};
TEST(Matcher, BindMatchedNodes) {
- DeclarationMatcher ClassX = has(Id("x", Class(HasName("X"))));
+ DeclarationMatcher ClassX = has(id("x", Class(hasName("X"))));
EXPECT_TRUE(matchAndVerifyResultTrue("class X {};",
ClassX, new VerifyIdIsBoundToDecl<clang::CXXRecordDecl>("x")));
@@ -550,14 +550,14 @@
EXPECT_TRUE(matchAndVerifyResultFalse("class X {};",
ClassX, new VerifyIdIsBoundToDecl<clang::CXXRecordDecl>("other-id")));
- TypeMatcher TypeAHasClassB = HasDeclaration(
- Class(HasName("A"), has(Id("b", Class(HasName("B"))))));
+ TypeMatcher TypeAHasClassB = hasDeclaration(
+ Class(hasName("A"), has(id("b", Class(hasName("B"))))));
EXPECT_TRUE(matchAndVerifyResultTrue("class A { public: A *a; class B {}; };",
TypeAHasClassB,
new VerifyIdIsBoundToDecl<clang::Decl>("b")));
- StatementMatcher MethodX = Id("x", Call(Callee(Method(HasName("x")))));
+ StatementMatcher MethodX = id("x", Call(callee(Method(hasName("x")))));
EXPECT_TRUE(matchAndVerifyResultTrue("class A { void x() { x(); } };",
MethodX,
@@ -565,54 +565,54 @@
}
TEST(HasType, TakesQualTypeMatcherAndMatchesExpr) {
- TypeMatcher ClassX = HasDeclaration(Class(HasName("X")));
+ TypeMatcher ClassX = hasDeclaration(Class(hasName("X")));
EXPECT_TRUE(
- matches("class X {}; void y(X &x) { x; }", Expression(HasType(ClassX))));
+ matches("class X {}; void y(X &x) { x; }", Expression(hasType(ClassX))));
EXPECT_TRUE(
notMatches("class X {}; void y(X *x) { x; }",
- Expression(HasType(ClassX))));
+ Expression(hasType(ClassX))));
EXPECT_TRUE(
matches("class X {}; void y(X *x) { x; }",
- Expression(HasType(PointsTo(ClassX)))));
+ Expression(hasType(pointsTo(ClassX)))));
}
TEST(HasType, TakesQualTypeMatcherAndMatchesValueDecl) {
- TypeMatcher ClassX = HasDeclaration(Class(HasName("X")));
+ TypeMatcher ClassX = hasDeclaration(Class(hasName("X")));
EXPECT_TRUE(
- matches("class X {}; void y() { X x; }", Variable(HasType(ClassX))));
+ matches("class X {}; void y() { X x; }", Variable(hasType(ClassX))));
EXPECT_TRUE(
- notMatches("class X {}; void y() { X *x; }", Variable(HasType(ClassX))));
+ notMatches("class X {}; void y() { X *x; }", Variable(hasType(ClassX))));
EXPECT_TRUE(
matches("class X {}; void y() { X *x; }",
- Variable(HasType(PointsTo(ClassX)))));
+ Variable(hasType(pointsTo(ClassX)))));
}
TEST(HasType, TakesDeclMatcherAndMatchesExpr) {
- DeclarationMatcher ClassX = Class(HasName("X"));
+ DeclarationMatcher ClassX = Class(hasName("X"));
EXPECT_TRUE(
- matches("class X {}; void y(X &x) { x; }", Expression(HasType(ClassX))));
+ matches("class X {}; void y(X &x) { x; }", Expression(hasType(ClassX))));
EXPECT_TRUE(
notMatches("class X {}; void y(X *x) { x; }",
- Expression(HasType(ClassX))));
+ Expression(hasType(ClassX))));
}
TEST(HasType, TakesDeclMatcherAndMatchesValueDecl) {
- DeclarationMatcher ClassX = Class(HasName("X"));
+ DeclarationMatcher ClassX = Class(hasName("X"));
EXPECT_TRUE(
- matches("class X {}; void y() { X x; }", Variable(HasType(ClassX))));
+ matches("class X {}; void y() { X x; }", Variable(hasType(ClassX))));
EXPECT_TRUE(
- notMatches("class X {}; void y() { X *x; }", Variable(HasType(ClassX))));
+ notMatches("class X {}; void y() { X *x; }", Variable(hasType(ClassX))));
}
TEST(Matcher, Call) {
// FIXME: Do we want to overload Call() to directly take
// Matcher<clang::Decl>, too?
- StatementMatcher MethodX = Call(HasDeclaration(Method(HasName("x"))));
+ StatementMatcher MethodX = Call(hasDeclaration(Method(hasName("x"))));
EXPECT_TRUE(matches("class Y { void x() { x(); } };", MethodX));
EXPECT_TRUE(notMatches("class Y { void x() {} };", MethodX));
- StatementMatcher MethodOnY = Call(On(HasType(Class(HasName("Y")))));
+ StatementMatcher MethodOnY = Call(on(hasType(Class(hasName("Y")))));
EXPECT_TRUE(
matches("class Y { public: void x(); }; void z() { Y y; y.x(); }",
@@ -631,7 +631,7 @@
MethodOnY));
StatementMatcher MethodOnYPointer =
- Call(On(HasType(PointsTo(Class(HasName("Y"))))));
+ Call(on(hasType(pointsTo(Class(hasName("Y"))))));
EXPECT_TRUE(
matches("class Y { public: void x(); }; void z() { Y *y; y->x(); }",
@@ -678,12 +678,12 @@
TEST(Matcher, HasOperatorNameForOverloadedOperatorCall) {
StatementMatcher OpCallAndAnd =
- OverloadedOperatorCall(HasOverloadedOperatorName("&&"));
+ OverloadedOperatorCall(hasOverloadedOperatorName("&&"));
EXPECT_TRUE(matches("class Y { }; "
"bool operator&&(Y x, Y y) { return true; }; "
"Y a; Y b; bool c = a && b;", OpCallAndAnd));
StatementMatcher OpCallLessLess =
- OverloadedOperatorCall(HasOverloadedOperatorName("<<"));
+ OverloadedOperatorCall(hasOverloadedOperatorName("<<"));
EXPECT_TRUE(notMatches("class Y { }; "
"bool operator&&(Y x, Y y) { return true; }; "
"Y a; Y b; bool c = a && b;",
@@ -691,7 +691,7 @@
}
TEST(Matcher, ThisPointerType) {
- StatementMatcher MethodOnY = Call(ThisPointerType(Class(HasName("Y"))));
+ StatementMatcher MethodOnY = Call(thisPointerType(Class(hasName("Y"))));
EXPECT_TRUE(
matches("class Y { public: void x(); }; void z() { Y y; y.x(); }",
@@ -721,9 +721,9 @@
TEST(Matcher, VariableUsage) {
StatementMatcher Reference =
- DeclarationReference(To(
- Variable(HasInitializer(
- Call(ThisPointerType(Class(HasName("Y"))))))));
+ DeclarationReference(to(
+ Variable(hasInitializer(
+ Call(thisPointerType(Class(hasName("Y"))))))));
EXPECT_TRUE(matches(
"class Y {"
@@ -747,7 +747,7 @@
TEST(Matcher, CalledVariable) {
StatementMatcher CallOnVariableY = Expression(
- Call(On(DeclarationReference(To(Variable(HasName("y")))))));
+ Call(on(DeclarationReference(to(Variable(hasName("y")))))));
EXPECT_TRUE(matches(
"class Y { public: void x() { Y y; y.x(); } };", CallOnVariableY));
@@ -794,33 +794,33 @@
TEST(IsArrow, MatchesMemberVariablesViaArrow) {
EXPECT_TRUE(matches("class Y { void x() { this->y; } int y; };",
- MemberExpression(IsArrow())));
+ MemberExpression(isArrow())));
EXPECT_TRUE(matches("class Y { void x() { y; } int y; };",
- MemberExpression(IsArrow())));
+ MemberExpression(isArrow())));
EXPECT_TRUE(notMatches("class Y { void x() { (*this).y; } int y; };",
- MemberExpression(IsArrow())));
+ MemberExpression(isArrow())));
}
TEST(IsArrow, MatchesStaticMemberVariablesViaArrow) {
EXPECT_TRUE(matches("class Y { void x() { this->y; } static int y; };",
- MemberExpression(IsArrow())));
+ MemberExpression(isArrow())));
EXPECT_TRUE(notMatches("class Y { void x() { y; } static int y; };",
- MemberExpression(IsArrow())));
+ MemberExpression(isArrow())));
EXPECT_TRUE(notMatches("class Y { void x() { (*this).y; } static int y; };",
- MemberExpression(IsArrow())));
+ MemberExpression(isArrow())));
}
TEST(IsArrow, MatchesMemberCallsViaArrow) {
EXPECT_TRUE(matches("class Y { void x() { this->x(); } };",
- MemberExpression(IsArrow())));
+ MemberExpression(isArrow())));
EXPECT_TRUE(matches("class Y { void x() { x(); } };",
- MemberExpression(IsArrow())));
+ MemberExpression(isArrow())));
EXPECT_TRUE(notMatches("class Y { void x() { Y y; y.x(); } };",
- MemberExpression(IsArrow())));
+ MemberExpression(isArrow())));
}
TEST(Callee, MatchesDeclarations) {
- StatementMatcher CallMethodX = Call(Callee(Method(HasName("x"))));
+ StatementMatcher CallMethodX = Call(callee(Method(hasName("x"))));
EXPECT_TRUE(matches("class Y { void x() { x(); } };", CallMethodX));
EXPECT_TRUE(notMatches("class Y { void x() {} };", CallMethodX));
@@ -828,13 +828,13 @@
TEST(Callee, MatchesMemberExpressions) {
EXPECT_TRUE(matches("class Y { void x() { this->x(); } };",
- Call(Callee(MemberExpression()))));
+ Call(callee(MemberExpression()))));
EXPECT_TRUE(
- notMatches("class Y { void x() { this->x(); } };", Call(Callee(Call()))));
+ notMatches("class Y { void x() { this->x(); } };", Call(callee(Call()))));
}
TEST(Function, MatchesFunctionDeclarations) {
- StatementMatcher CallFunctionF = Call(Callee(Function(HasName("f"))));
+ StatementMatcher CallFunctionF = Call(callee(Function(hasName("f"))));
EXPECT_TRUE(matches("void f() { f(); }", CallFunctionF));
EXPECT_TRUE(notMatches("void f() { }", CallFunctionF));
@@ -858,7 +858,7 @@
TEST(Matcher, Argument) {
StatementMatcher CallArgumentY = Expression(Call(
- HasArgument(0, DeclarationReference(To(Variable(HasName("y")))))));
+ hasArgument(0, DeclarationReference(to(Variable(hasName("y")))))));
EXPECT_TRUE(matches("void x(int) { int y; x(y); }", CallArgumentY));
EXPECT_TRUE(
@@ -866,20 +866,20 @@
EXPECT_TRUE(notMatches("void x(int) { int z; x(z); }", CallArgumentY));
StatementMatcher WrongIndex = Expression(Call(
- HasArgument(42, DeclarationReference(To(Variable(HasName("y")))))));
+ hasArgument(42, DeclarationReference(to(Variable(hasName("y")))))));
EXPECT_TRUE(notMatches("void x(int) { int y; x(y); }", WrongIndex));
}
TEST(Matcher, AnyArgument) {
StatementMatcher CallArgumentY = Expression(Call(
- HasAnyArgument(DeclarationReference(To(Variable(HasName("y")))))));
+ hasAnyArgument(DeclarationReference(to(Variable(hasName("y")))))));
EXPECT_TRUE(matches("void x(int, int) { int y; x(1, y); }", CallArgumentY));
EXPECT_TRUE(matches("void x(int, int) { int y; x(y, 42); }", CallArgumentY));
EXPECT_TRUE(notMatches("void x(int, int) { x(1, 2); }", CallArgumentY));
}
TEST(Matcher, ArgumentCount) {
- StatementMatcher Call1Arg = Expression(Call(ArgumentCountIs(1)));
+ StatementMatcher Call1Arg = Expression(Call(argumentCountIs(1)));
EXPECT_TRUE(matches("void x(int) { x(0); }", Call1Arg));
EXPECT_TRUE(matches("class X { void x(int) { x(0); } };", Call1Arg));
@@ -888,7 +888,7 @@
TEST(Matcher, References) {
DeclarationMatcher ReferenceClassX = Variable(
- HasType(References(Class(HasName("X")))));
+ hasType(references(Class(hasName("X")))));
EXPECT_TRUE(matches("class X {}; void y(X y) { X &x = y; }",
ReferenceClassX));
EXPECT_TRUE(
@@ -901,49 +901,49 @@
TEST(HasParameter, CallsInnerMatcher) {
EXPECT_TRUE(matches("class X { void x(int) {} };",
- Method(HasParameter(0, Variable()))));
+ Method(hasParameter(0, Variable()))));
EXPECT_TRUE(notMatches("class X { void x(int) {} };",
- Method(HasParameter(0, HasName("x")))));
+ Method(hasParameter(0, hasName("x")))));
}
TEST(HasParameter, DoesNotMatchIfIndexOutOfBounds) {
EXPECT_TRUE(notMatches("class X { void x(int) {} };",
- Method(HasParameter(42, Variable()))));
+ Method(hasParameter(42, Variable()))));
}
TEST(HasType, MatchesParameterVariableTypesStrictly) {
EXPECT_TRUE(matches("class X { void x(X x) {} };",
- Method(HasParameter(0, HasType(Class(HasName("X")))))));
+ Method(hasParameter(0, hasType(Class(hasName("X")))))));
EXPECT_TRUE(notMatches("class X { void x(const X &x) {} };",
- Method(HasParameter(0, HasType(Class(HasName("X")))))));
+ Method(hasParameter(0, hasType(Class(hasName("X")))))));
EXPECT_TRUE(matches("class X { void x(const X *x) {} };",
- Method(HasParameter(0, HasType(PointsTo(Class(HasName("X"))))))));
+ Method(hasParameter(0, hasType(pointsTo(Class(hasName("X"))))))));
EXPECT_TRUE(matches("class X { void x(const X &x) {} };",
- Method(HasParameter(0, HasType(References(Class(HasName("X"))))))));
+ Method(hasParameter(0, hasType(references(Class(hasName("X"))))))));
}
TEST(HasAnyParameter, MatchesIndependentlyOfPosition) {
EXPECT_TRUE(matches("class Y {}; class X { void x(X x, Y y) {} };",
- Method(HasAnyParameter(HasType(Class(HasName("X")))))));
+ Method(hasAnyParameter(hasType(Class(hasName("X")))))));
EXPECT_TRUE(matches("class Y {}; class X { void x(Y y, X x) {} };",
- Method(HasAnyParameter(HasType(Class(HasName("X")))))));
+ Method(hasAnyParameter(hasType(Class(hasName("X")))))));
}
TEST(HasAnyParameter, DoesntMatchIfInnerMatcherDoesntMatch) {
EXPECT_TRUE(notMatches("class Y {}; class X { void x(int) {} };",
- Method(HasAnyParameter(HasType(Class(HasName("X")))))));
+ Method(hasAnyParameter(hasType(Class(hasName("X")))))));
}
TEST(HasAnyParameter, DoesNotMatchThisPointer) {
EXPECT_TRUE(notMatches("class Y {}; class X { void x() {} };",
- Method(HasAnyParameter(HasType(PointsTo(Class(HasName("X"))))))));
+ Method(hasAnyParameter(hasType(pointsTo(Class(hasName("X"))))))));
}
TEST(HasName, MatchesParameterVariableDeclartions) {
EXPECT_TRUE(matches("class Y {}; class X { void x(int x) {} };",
- Method(HasAnyParameter(HasName("x")))));
+ Method(hasAnyParameter(hasName("x")))));
EXPECT_TRUE(notMatches("class Y {}; class X { void x(int) {} };",
- Method(HasAnyParameter(HasName("x")))));
+ Method(hasAnyParameter(hasName("x")))));
}
TEST(Matcher, ConstructorCall) {
@@ -962,7 +962,7 @@
TEST(Matcher, ConstructorArgument) {
StatementMatcher Constructor = Expression(ConstructorCall(
- HasArgument(0, DeclarationReference(To(Variable(HasName("y")))))));
+ hasArgument(0, DeclarationReference(to(Variable(hasName("y")))))));
EXPECT_TRUE(
matches("class X { public: X(int); }; void x() { int y; X x(y); }",
@@ -978,7 +978,7 @@
Constructor));
StatementMatcher WrongIndex = Expression(ConstructorCall(
- HasArgument(42, DeclarationReference(To(Variable(HasName("y")))))));
+ hasArgument(42, DeclarationReference(to(Variable(hasName("y")))))));
EXPECT_TRUE(
notMatches("class X { public: X(int); }; void x() { int y; X x(y); }",
WrongIndex));
@@ -986,7 +986,7 @@
TEST(Matcher, ConstructorArgumentCount) {
StatementMatcher Constructor1Arg =
- Expression(ConstructorCall(ArgumentCountIs(1)));
+ Expression(ConstructorCall(argumentCountIs(1)));
EXPECT_TRUE(
matches("class X { public: X(int); }; void x() { X x(0); }",
@@ -1035,33 +1035,33 @@
TEST(ConstructorDeclaration, SimpleCase) {
EXPECT_TRUE(matches("class Foo { Foo(int i); };",
- Constructor(OfClass(HasName("Foo")))));
+ Constructor(ofClass(hasName("Foo")))));
EXPECT_TRUE(notMatches("class Foo { Foo(int i); };",
- Constructor(OfClass(HasName("Bar")))));
+ Constructor(ofClass(hasName("Bar")))));
}
TEST(ConstructorDeclaration, IsImplicit) {
// This one doesn't match because the constructor is not added by the
// compiler (it is not needed).
EXPECT_TRUE(notMatches("class Foo { };",
- Constructor(IsImplicit())));
+ Constructor(isImplicit())));
// The compiler added the implicit default constructor.
EXPECT_TRUE(matches("class Foo { }; Foo* f = new Foo();",
- Constructor(IsImplicit())));
+ Constructor(isImplicit())));
EXPECT_TRUE(matches("class Foo { Foo(){} };",
- Constructor(Not(IsImplicit()))));
+ Constructor(unless(isImplicit()))));
}
TEST(HasAnyConstructorInitializer, SimpleCase) {
EXPECT_TRUE(notMatches(
"class Foo { Foo() { } };",
- Constructor(HasAnyConstructorInitializer(True()))));
+ Constructor(hasAnyConstructorInitializer(anything()))));
EXPECT_TRUE(matches(
"class Foo {"
" Foo() : foo_() { }"
" int foo_;"
"};",
- Constructor(HasAnyConstructorInitializer(True()))));
+ Constructor(hasAnyConstructorInitializer(anything()))));
}
TEST(HasAnyConstructorInitializer, ForField) {
@@ -1072,12 +1072,12 @@
" Baz foo_;"
" Baz bar_;"
"};";
- EXPECT_TRUE(matches(Code, Constructor(HasAnyConstructorInitializer(
- ForField(HasType(Class(HasName("Baz"))))))));
- EXPECT_TRUE(matches(Code, Constructor(HasAnyConstructorInitializer(
- ForField(HasName("foo_"))))));
- EXPECT_TRUE(notMatches(Code, Constructor(HasAnyConstructorInitializer(
- ForField(HasType(Class(HasName("Bar"))))))));
+ EXPECT_TRUE(matches(Code, Constructor(hasAnyConstructorInitializer(
+ forField(hasType(Class(hasName("Baz"))))))));
+ EXPECT_TRUE(matches(Code, Constructor(hasAnyConstructorInitializer(
+ forField(hasName("foo_"))))));
+ EXPECT_TRUE(notMatches(Code, Constructor(hasAnyConstructorInitializer(
+ forField(hasType(Class(hasName("Bar"))))))));
}
TEST(HasAnyConstructorInitializer, WithInitializer) {
@@ -1086,10 +1086,10 @@
" Foo() : foo_(0) { }"
" int foo_;"
"};";
- EXPECT_TRUE(matches(Code, Constructor(HasAnyConstructorInitializer(
- WithInitializer(IntegerLiteral(Equals(0)))))));
- EXPECT_TRUE(notMatches(Code, Constructor(HasAnyConstructorInitializer(
- WithInitializer(IntegerLiteral(Equals(1)))))));
+ EXPECT_TRUE(matches(Code, Constructor(hasAnyConstructorInitializer(
+ withInitializer(IntegerLiteral(equals(0)))))));
+ EXPECT_TRUE(notMatches(Code, Constructor(hasAnyConstructorInitializer(
+ withInitializer(IntegerLiteral(equals(1)))))));
}
TEST(HasAnyConstructorInitializer, IsWritten) {
@@ -1100,12 +1100,12 @@
" Bar foo_;"
" Bar bar_;"
"};";
- EXPECT_TRUE(matches(Code, Constructor(HasAnyConstructorInitializer(
- AllOf(ForField(HasName("foo_")), IsWritten())))));
- EXPECT_TRUE(notMatches(Code, Constructor(HasAnyConstructorInitializer(
- AllOf(ForField(HasName("bar_")), IsWritten())))));
- EXPECT_TRUE(matches(Code, Constructor(HasAnyConstructorInitializer(
- AllOf(ForField(HasName("bar_")), Not(IsWritten()))))));
+ EXPECT_TRUE(matches(Code, Constructor(hasAnyConstructorInitializer(
+ allOf(forField(hasName("foo_")), isWritten())))));
+ EXPECT_TRUE(notMatches(Code, Constructor(hasAnyConstructorInitializer(
+ allOf(forField(hasName("bar_")), isWritten())))));
+ EXPECT_TRUE(matches(Code, Constructor(hasAnyConstructorInitializer(
+ allOf(forField(hasName("bar_")), unless(isWritten()))))));
}
TEST(Matcher, NewExpression) {
@@ -1121,8 +1121,8 @@
TEST(Matcher, NewExpressionArgument) {
StatementMatcher New = Expression(ConstructorCall(
- HasArgument(
- 0, DeclarationReference(To(Variable(HasName("y")))))));
+ hasArgument(
+ 0, DeclarationReference(to(Variable(hasName("y")))))));
EXPECT_TRUE(
matches("class X { public: X(int); }; void x() { int y; new X(y); }",
@@ -1135,15 +1135,15 @@
New));
StatementMatcher WrongIndex = Expression(ConstructorCall(
- HasArgument(
- 42, DeclarationReference(To(Variable(HasName("y")))))));
+ hasArgument(
+ 42, DeclarationReference(to(Variable(hasName("y")))))));
EXPECT_TRUE(
notMatches("class X { public: X(int); }; void x() { int y; new X(y); }",
WrongIndex));
}
TEST(Matcher, NewExpressionArgumentCount) {
- StatementMatcher New = ConstructorCall(ArgumentCountIs(1));
+ StatementMatcher New = ConstructorCall(argumentCountIs(1));
EXPECT_TRUE(
matches("class X { public: X(int); }; void x() { new X(0); }", New));
@@ -1199,7 +1199,7 @@
}
TEST(Matcher, Conditions) {
- StatementMatcher Condition = If(HasCondition(BoolLiteral(Equals(true))));
+ StatementMatcher Condition = If(hasCondition(BoolLiteral(equals(true))));
EXPECT_TRUE(matches("void x() { if (true) {} }", Condition));
EXPECT_TRUE(notMatches("void x() { if (false) {} }", Condition));
@@ -1209,7 +1209,7 @@
}
TEST(MatchBinaryOperator, HasOperatorName) {
- StatementMatcher OperatorOr = BinaryOperator(HasOperatorName("||"));
+ StatementMatcher OperatorOr = BinaryOperator(hasOperatorName("||"));
EXPECT_TRUE(matches("void x() { true || false; }", OperatorOr));
EXPECT_TRUE(notMatches("void x() { true && false; }", OperatorOr));
@@ -1217,8 +1217,8 @@
TEST(MatchBinaryOperator, HasLHSAndHasRHS) {
StatementMatcher OperatorTrueFalse =
- BinaryOperator(HasLHS(BoolLiteral(Equals(true))),
- HasRHS(BoolLiteral(Equals(false))));
+ BinaryOperator(hasLHS(BoolLiteral(equals(true))),
+ hasRHS(BoolLiteral(equals(false))));
EXPECT_TRUE(matches("void x() { true || false; }", OperatorTrueFalse));
EXPECT_TRUE(matches("void x() { true && false; }", OperatorTrueFalse));
@@ -1227,7 +1227,7 @@
TEST(MatchBinaryOperator, HasEitherOperand) {
StatementMatcher HasOperand =
- BinaryOperator(HasEitherOperand(BoolLiteral(Equals(false))));
+ BinaryOperator(hasEitherOperand(BoolLiteral(equals(false))));
EXPECT_TRUE(matches("void x() { true || false; }", HasOperand));
EXPECT_TRUE(matches("void x() { false && true; }", HasOperand));
@@ -1239,91 +1239,91 @@
// a way we expect.
// FIXME: Operator ','
EXPECT_TRUE(
- matches("void x() { 3, 4; }", BinaryOperator(HasOperatorName(","))));
+ matches("void x() { 3, 4; }", BinaryOperator(hasOperatorName(","))));
EXPECT_TRUE(
matches("bool b; bool c = (b = true);",
- BinaryOperator(HasOperatorName("="))));
+ BinaryOperator(hasOperatorName("="))));
EXPECT_TRUE(
- matches("bool b = 1 != 2;", BinaryOperator(HasOperatorName("!="))));
+ matches("bool b = 1 != 2;", BinaryOperator(hasOperatorName("!="))));
EXPECT_TRUE(
- matches("bool b = 1 == 2;", BinaryOperator(HasOperatorName("=="))));
- EXPECT_TRUE(matches("bool b = 1 < 2;", BinaryOperator(HasOperatorName("<"))));
+ matches("bool b = 1 == 2;", BinaryOperator(hasOperatorName("=="))));
+ EXPECT_TRUE(matches("bool b = 1 < 2;", BinaryOperator(hasOperatorName("<"))));
EXPECT_TRUE(
- matches("bool b = 1 <= 2;", BinaryOperator(HasOperatorName("<="))));
+ matches("bool b = 1 <= 2;", BinaryOperator(hasOperatorName("<="))));
EXPECT_TRUE(
- matches("int i = 1 << 2;", BinaryOperator(HasOperatorName("<<"))));
+ matches("int i = 1 << 2;", BinaryOperator(hasOperatorName("<<"))));
EXPECT_TRUE(
matches("int i = 1; int j = (i <<= 2);",
- BinaryOperator(HasOperatorName("<<="))));
- EXPECT_TRUE(matches("bool b = 1 > 2;", BinaryOperator(HasOperatorName(">"))));
+ BinaryOperator(hasOperatorName("<<="))));
+ EXPECT_TRUE(matches("bool b = 1 > 2;", BinaryOperator(hasOperatorName(">"))));
EXPECT_TRUE(
- matches("bool b = 1 >= 2;", BinaryOperator(HasOperatorName(">="))));
+ matches("bool b = 1 >= 2;", BinaryOperator(hasOperatorName(">="))));
EXPECT_TRUE(
- matches("int i = 1 >> 2;", BinaryOperator(HasOperatorName(">>"))));
+ matches("int i = 1 >> 2;", BinaryOperator(hasOperatorName(">>"))));
EXPECT_TRUE(
matches("int i = 1; int j = (i >>= 2);",
- BinaryOperator(HasOperatorName(">>="))));
+ BinaryOperator(hasOperatorName(">>="))));
EXPECT_TRUE(
- matches("int i = 42 ^ 23;", BinaryOperator(HasOperatorName("^"))));
+ matches("int i = 42 ^ 23;", BinaryOperator(hasOperatorName("^"))));
EXPECT_TRUE(
matches("int i = 42; int j = (i ^= 42);",
- BinaryOperator(HasOperatorName("^="))));
+ BinaryOperator(hasOperatorName("^="))));
EXPECT_TRUE(
- matches("int i = 42 % 23;", BinaryOperator(HasOperatorName("%"))));
+ matches("int i = 42 % 23;", BinaryOperator(hasOperatorName("%"))));
EXPECT_TRUE(
matches("int i = 42; int j = (i %= 42);",
- BinaryOperator(HasOperatorName("%="))));
+ BinaryOperator(hasOperatorName("%="))));
EXPECT_TRUE(
- matches("bool b = 42 &23;", BinaryOperator(HasOperatorName("&"))));
+ matches("bool b = 42 &23;", BinaryOperator(hasOperatorName("&"))));
EXPECT_TRUE(
matches("bool b = true && false;",
- BinaryOperator(HasOperatorName("&&"))));
+ BinaryOperator(hasOperatorName("&&"))));
EXPECT_TRUE(
matches("bool b = true; bool c = (b &= false);",
- BinaryOperator(HasOperatorName("&="))));
+ BinaryOperator(hasOperatorName("&="))));
EXPECT_TRUE(
- matches("bool b = 42 | 23;", BinaryOperator(HasOperatorName("|"))));
+ matches("bool b = 42 | 23;", BinaryOperator(hasOperatorName("|"))));
EXPECT_TRUE(
matches("bool b = true || false;",
- BinaryOperator(HasOperatorName("||"))));
+ BinaryOperator(hasOperatorName("||"))));
EXPECT_TRUE(
matches("bool b = true; bool c = (b |= false);",
- BinaryOperator(HasOperatorName("|="))));
+ BinaryOperator(hasOperatorName("|="))));
EXPECT_TRUE(
- matches("int i = 42 *23;", BinaryOperator(HasOperatorName("*"))));
+ matches("int i = 42 *23;", BinaryOperator(hasOperatorName("*"))));
EXPECT_TRUE(
matches("int i = 42; int j = (i *= 23);",
- BinaryOperator(HasOperatorName("*="))));
+ BinaryOperator(hasOperatorName("*="))));
EXPECT_TRUE(
- matches("int i = 42 / 23;", BinaryOperator(HasOperatorName("/"))));
+ matches("int i = 42 / 23;", BinaryOperator(hasOperatorName("/"))));
EXPECT_TRUE(
matches("int i = 42; int j = (i /= 23);",
- BinaryOperator(HasOperatorName("/="))));
+ BinaryOperator(hasOperatorName("/="))));
EXPECT_TRUE(
- matches("int i = 42 + 23;", BinaryOperator(HasOperatorName("+"))));
+ matches("int i = 42 + 23;", BinaryOperator(hasOperatorName("+"))));
EXPECT_TRUE(
matches("int i = 42; int j = (i += 23);",
- BinaryOperator(HasOperatorName("+="))));
+ BinaryOperator(hasOperatorName("+="))));
EXPECT_TRUE(
- matches("int i = 42 - 23;", BinaryOperator(HasOperatorName("-"))));
+ matches("int i = 42 - 23;", BinaryOperator(hasOperatorName("-"))));
EXPECT_TRUE(
matches("int i = 42; int j = (i -= 23);",
- BinaryOperator(HasOperatorName("-="))));
+ BinaryOperator(hasOperatorName("-="))));
EXPECT_TRUE(
matches("struct A { void x() { void (A::*a)(); (this->*a)(); } };",
- BinaryOperator(HasOperatorName("->*"))));
+ BinaryOperator(hasOperatorName("->*"))));
EXPECT_TRUE(
matches("struct A { void x() { void (A::*a)(); ((*this).*a)(); } };",
- BinaryOperator(HasOperatorName(".*"))));
+ BinaryOperator(hasOperatorName(".*"))));
// Member expressions as operators are not supported in matches.
EXPECT_TRUE(
notMatches("struct A { void x(A *a) { a->x(this); } };",
- BinaryOperator(HasOperatorName("->"))));
+ BinaryOperator(hasOperatorName("->"))));
// Initializer assignments are not represented as operator equals.
EXPECT_TRUE(
- notMatches("bool b = true;", BinaryOperator(HasOperatorName("="))));
+ notMatches("bool b = true;", BinaryOperator(hasOperatorName("="))));
// Array indexing is not represented as operator.
EXPECT_TRUE(notMatches("int a[42]; void x() { a[23]; }", UnaryOperator()));
@@ -1336,7 +1336,7 @@
}
TEST(MatchUnaryOperator, HasOperatorName) {
- StatementMatcher OperatorNot = UnaryOperator(HasOperatorName("!"));
+ StatementMatcher OperatorNot = UnaryOperator(hasOperatorName("!"));
EXPECT_TRUE(matches("void x() { !true; } ", OperatorNot));
EXPECT_TRUE(notMatches("void x() { true; } ", OperatorNot));
@@ -1344,7 +1344,7 @@
TEST(MatchUnaryOperator, HasUnaryOperand) {
StatementMatcher OperatorOnFalse =
- UnaryOperator(HasUnaryOperand(BoolLiteral(Equals(false))));
+ UnaryOperator(hasUnaryOperand(BoolLiteral(equals(false))));
EXPECT_TRUE(matches("void x() { !false; }", OperatorOnFalse));
EXPECT_TRUE(notMatches("void x() { !true; }", OperatorOnFalse));
@@ -1353,24 +1353,24 @@
TEST(Matcher, UnaryOperatorTypes) {
// Integration test that verifies the AST provides all unary operators in
// a way we expect.
- EXPECT_TRUE(matches("bool b = !true;", UnaryOperator(HasOperatorName("!"))));
+ EXPECT_TRUE(matches("bool b = !true;", UnaryOperator(hasOperatorName("!"))));
EXPECT_TRUE(
- matches("bool b; bool *p = &b;", UnaryOperator(HasOperatorName("&"))));
- EXPECT_TRUE(matches("int i = ~ 1;", UnaryOperator(HasOperatorName("~"))));
+ matches("bool b; bool *p = &b;", UnaryOperator(hasOperatorName("&"))));
+ EXPECT_TRUE(matches("int i = ~ 1;", UnaryOperator(hasOperatorName("~"))));
EXPECT_TRUE(
- matches("bool *p; bool b = *p;", UnaryOperator(HasOperatorName("*"))));
+ matches("bool *p; bool b = *p;", UnaryOperator(hasOperatorName("*"))));
EXPECT_TRUE(
- matches("int i; int j = +i;", UnaryOperator(HasOperatorName("+"))));
+ matches("int i; int j = +i;", UnaryOperator(hasOperatorName("+"))));
EXPECT_TRUE(
- matches("int i; int j = -i;", UnaryOperator(HasOperatorName("-"))));
+ matches("int i; int j = -i;", UnaryOperator(hasOperatorName("-"))));
EXPECT_TRUE(
- matches("int i; int j = ++i;", UnaryOperator(HasOperatorName("++"))));
+ matches("int i; int j = ++i;", UnaryOperator(hasOperatorName("++"))));
EXPECT_TRUE(
- matches("int i; int j = i++;", UnaryOperator(HasOperatorName("++"))));
+ matches("int i; int j = i++;", UnaryOperator(hasOperatorName("++"))));
EXPECT_TRUE(
- matches("int i; int j = --i;", UnaryOperator(HasOperatorName("--"))));
+ matches("int i; int j = --i;", UnaryOperator(hasOperatorName("--"))));
EXPECT_TRUE(
- matches("int i; int j = i--;", UnaryOperator(HasOperatorName("--"))));
+ matches("int i; int j = i--;", UnaryOperator(hasOperatorName("--"))));
// We don't match conversion operators.
EXPECT_TRUE(notMatches("int i; double d = (double)i;", UnaryOperator()));
@@ -1382,20 +1382,20 @@
// FIXME: We probably want to add that.
EXPECT_TRUE(notMatches(
"struct A { bool operator!() const { return false; } };"
- "void x() { A a; !a; }", UnaryOperator(HasOperatorName("!"))));
+ "void x() { A a; !a; }", UnaryOperator(hasOperatorName("!"))));
}
TEST(Matcher, ConditionalOperator) {
StatementMatcher Conditional = ConditionalOperator(
- HasCondition(BoolLiteral(Equals(true))),
- HasTrueExpression(BoolLiteral(Equals(false))));
+ hasCondition(BoolLiteral(equals(true))),
+ hasTrueExpression(BoolLiteral(equals(false))));
EXPECT_TRUE(matches("void x() { true ? false : true; }", Conditional));
EXPECT_TRUE(notMatches("void x() { false ? false : true; }", Conditional));
EXPECT_TRUE(notMatches("void x() { true ? true : false; }", Conditional));
StatementMatcher ConditionalFalse = ConditionalOperator(
- HasFalseExpression(BoolLiteral(Equals(false))));
+ hasFalseExpression(BoolLiteral(equals(false))));
EXPECT_TRUE(matches("void x() { true ? true : false; }", ConditionalFalse));
EXPECT_TRUE(
@@ -1404,82 +1404,82 @@
TEST(Matcher, HasNameSupportsNamespaces) {
EXPECT_TRUE(matches("namespace a { namespace b { class C; } }",
- Class(HasName("a::b::C"))));
+ Class(hasName("a::b::C"))));
EXPECT_TRUE(matches("namespace a { namespace b { class C; } }",
- Class(HasName("::a::b::C"))));
+ Class(hasName("::a::b::C"))));
EXPECT_TRUE(matches("namespace a { namespace b { class C; } }",
- Class(HasName("b::C"))));
+ Class(hasName("b::C"))));
EXPECT_TRUE(matches("namespace a { namespace b { class C; } }",
- Class(HasName("C"))));
+ Class(hasName("C"))));
EXPECT_TRUE(notMatches("namespace a { namespace b { class C; } }",
- Class(HasName("c::b::C"))));
+ Class(hasName("c::b::C"))));
EXPECT_TRUE(notMatches("namespace a { namespace b { class C; } }",
- Class(HasName("a::c::C"))));
+ Class(hasName("a::c::C"))));
EXPECT_TRUE(notMatches("namespace a { namespace b { class C; } }",
- Class(HasName("a::b::A"))));
+ Class(hasName("a::b::A"))));
EXPECT_TRUE(notMatches("namespace a { namespace b { class C; } }",
- Class(HasName("::C"))));
+ Class(hasName("::C"))));
EXPECT_TRUE(notMatches("namespace a { namespace b { class C; } }",
- Class(HasName("::b::C"))));
+ Class(hasName("::b::C"))));
EXPECT_TRUE(notMatches("namespace a { namespace b { class C; } }",
- Class(HasName("z::a::b::C"))));
+ Class(hasName("z::a::b::C"))));
EXPECT_TRUE(notMatches("namespace a { namespace b { class C; } }",
- Class(HasName("a+b::C"))));
+ Class(hasName("a+b::C"))));
EXPECT_TRUE(notMatches("namespace a { namespace b { class AC; } }",
- Class(HasName("C"))));
+ Class(hasName("C"))));
}
TEST(Matcher, HasNameSupportsOuterClasses) {
EXPECT_TRUE(
- matches("class A { class B { class C; }; };", Class(HasName("A::B::C"))));
+ matches("class A { class B { class C; }; };", Class(hasName("A::B::C"))));
EXPECT_TRUE(
matches("class A { class B { class C; }; };",
- Class(HasName("::A::B::C"))));
+ Class(hasName("::A::B::C"))));
EXPECT_TRUE(
- matches("class A { class B { class C; }; };", Class(HasName("B::C"))));
+ matches("class A { class B { class C; }; };", Class(hasName("B::C"))));
EXPECT_TRUE(
- matches("class A { class B { class C; }; };", Class(HasName("C"))));
+ matches("class A { class B { class C; }; };", Class(hasName("C"))));
EXPECT_TRUE(
notMatches("class A { class B { class C; }; };",
- Class(HasName("c::B::C"))));
+ Class(hasName("c::B::C"))));
EXPECT_TRUE(
notMatches("class A { class B { class C; }; };",
- Class(HasName("A::c::C"))));
+ Class(hasName("A::c::C"))));
EXPECT_TRUE(
notMatches("class A { class B { class C; }; };",
- Class(HasName("A::B::A"))));
+ Class(hasName("A::B::A"))));
EXPECT_TRUE(
- notMatches("class A { class B { class C; }; };", Class(HasName("::C"))));
+ notMatches("class A { class B { class C; }; };", Class(hasName("::C"))));
EXPECT_TRUE(
notMatches("class A { class B { class C; }; };",
- Class(HasName("::B::C"))));
+ Class(hasName("::B::C"))));
EXPECT_TRUE(notMatches("class A { class B { class C; }; };",
- Class(HasName("z::A::B::C"))));
+ Class(hasName("z::A::B::C"))));
EXPECT_TRUE(
notMatches("class A { class B { class C; }; };",
- Class(HasName("A+B::C"))));
+ Class(hasName("A+B::C"))));
}
TEST(Matcher, IsDefinition) {
DeclarationMatcher DefinitionOfClassA =
- Class(HasName("A"), IsDefinition());
+ Class(hasName("A"), isDefinition());
EXPECT_TRUE(matches("class A {};", DefinitionOfClassA));
EXPECT_TRUE(notMatches("class A;", DefinitionOfClassA));
DeclarationMatcher DefinitionOfVariableA =
- Variable(HasName("a"), IsDefinition());
+ Variable(hasName("a"), isDefinition());
EXPECT_TRUE(matches("int a;", DefinitionOfVariableA));
EXPECT_TRUE(notMatches("extern int a;", DefinitionOfVariableA));
DeclarationMatcher DefinitionOfMethodA =
- Method(HasName("a"), IsDefinition());
+ Method(hasName("a"), isDefinition());
EXPECT_TRUE(matches("class A { void a() {} };", DefinitionOfMethodA));
EXPECT_TRUE(notMatches("class A { void a(); };", DefinitionOfMethodA));
}
TEST(Matcher, OfClass) {
- StatementMatcher Constructor = ConstructorCall(HasDeclaration(Method(
- OfClass(HasName("X")))));
+ StatementMatcher Constructor = ConstructorCall(hasDeclaration(Method(
+ ofClass(hasName("X")))));
EXPECT_TRUE(
matches("class X { public: X(); }; void x(int) { X x; }", Constructor));
@@ -1495,7 +1495,7 @@
EXPECT_TRUE(matches(
"class A { public: void x(); };"
"template <typename T> class B { public: void y() { T t; t.x(); } };"
- "void f() { B<A> b; b.y(); }", Call(Callee(Method(HasName("x"))))));
+ "void f() { B<A> b; b.y(); }", Call(callee(Method(hasName("x"))))));
EXPECT_TRUE(matches(
"class A { public: void x(); };"
@@ -1505,19 +1505,19 @@
"};"
"void f() {"
" C::B<A> b; b.y();"
- "}", Class(HasName("C"),
- hasDescendant(Call(Callee(Method(HasName("x"))))))));
+ "}", Class(hasName("C"),
+ hasDescendant(Call(callee(Method(hasName("x"))))))));
}
// For testing AST_MATCHER_P().
-AST_MATCHER_P(clang::Decl, Just, internal::Matcher<clang::Decl>, AMatcher) {
+AST_MATCHER_P(clang::Decl, just, internal::Matcher<clang::Decl>, AMatcher) {
// Make sure all special variables are used: node, match_finder,
// bound_nodes_builder, and the parameter named 'AMatcher'.
return AMatcher.matches(Node, Finder, Builder);
}
TEST(AstMatcherPMacro, Works) {
- DeclarationMatcher HasClassB = Just(has(Id("b", Class(HasName("B")))));
+ DeclarationMatcher HasClassB = just(has(id("b", Class(hasName("B")))));
EXPECT_TRUE(matchAndVerifyResultTrue("class A { class B {}; };",
HasClassB, new VerifyIdIsBoundToDecl<clang::Decl>("b")));
@@ -1530,7 +1530,7 @@
}
AST_POLYMORPHIC_MATCHER_P(
- PolymorphicHas, internal::Matcher<clang::Decl>, AMatcher) {
+ polymorphicHas, internal::Matcher<clang::Decl>, AMatcher) {
TOOLING_COMPILE_ASSERT((llvm::is_same<NodeType, clang::Decl>::value) ||
(llvm::is_same<NodeType, clang::Stmt>::value),
assert_node_type_is_accessible);
@@ -1542,7 +1542,7 @@
}
TEST(AstPolymorphicMatcherPMacro, Works) {
- DeclarationMatcher HasClassB = PolymorphicHas(Id("b", Class(HasName("B"))));
+ DeclarationMatcher HasClassB = polymorphicHas(id("b", Class(hasName("B"))));
EXPECT_TRUE(matchAndVerifyResultTrue("class A { class B {}; };",
HasClassB, new VerifyIdIsBoundToDecl<clang::Decl>("b")));
@@ -1554,7 +1554,7 @@
HasClassB, new VerifyIdIsBoundToDecl<clang::Decl>("b")));
StatementMatcher StatementHasClassB =
- PolymorphicHas(Class(HasName("B")));
+ polymorphicHas(Class(hasName("B")));
EXPECT_TRUE(matches("void x() { class B {}; }", StatementHasClassB));
}
@@ -1586,7 +1586,7 @@
TEST(HasBody, FindsBodyOfForLoop) {
StatementMatcher HasCompoundStatementBody =
- For(HasBody(CompoundStatement()));
+ For(hasBody(CompoundStatement()));
EXPECT_TRUE(matches("void f() { for(;;) {} }",
HasCompoundStatementBody));
EXPECT_TRUE(notMatches("void f() { for(;;); }",
@@ -1598,67 +1598,67 @@
// definition, and the function body itself must be a compound
// statement.
EXPECT_TRUE(matches("void f() { for (;;); }",
- CompoundStatement(HasAnySubstatement(For()))));
+ CompoundStatement(hasAnySubstatement(For()))));
}
TEST(HasAnySubstatement, IsNotRecursive) {
// It's really "has any immediate substatement".
EXPECT_TRUE(notMatches("void f() { if (true) for (;;); }",
- CompoundStatement(HasAnySubstatement(For()))));
+ CompoundStatement(hasAnySubstatement(For()))));
}
TEST(HasAnySubstatement, MatchesInNestedCompoundStatements) {
EXPECT_TRUE(matches("void f() { if (true) { for (;;); } }",
- CompoundStatement(HasAnySubstatement(For()))));
+ CompoundStatement(hasAnySubstatement(For()))));
}
TEST(HasAnySubstatement, FindsSubstatementBetweenOthers) {
EXPECT_TRUE(matches("void f() { 1; 2; 3; for (;;); 4; 5; 6; }",
- CompoundStatement(HasAnySubstatement(For()))));
+ CompoundStatement(hasAnySubstatement(For()))));
}
TEST(StatementCountIs, FindsNoStatementsInAnEmptyCompoundStatement) {
EXPECT_TRUE(matches("void f() { }",
- CompoundStatement(StatementCountIs(0))));
+ CompoundStatement(statementCountIs(0))));
EXPECT_TRUE(notMatches("void f() {}",
- CompoundStatement(StatementCountIs(1))));
+ CompoundStatement(statementCountIs(1))));
}
TEST(StatementCountIs, AppearsToMatchOnlyOneCount) {
EXPECT_TRUE(matches("void f() { 1; }",
- CompoundStatement(StatementCountIs(1))));
+ CompoundStatement(statementCountIs(1))));
EXPECT_TRUE(notMatches("void f() { 1; }",
- CompoundStatement(StatementCountIs(0))));
+ CompoundStatement(statementCountIs(0))));
EXPECT_TRUE(notMatches("void f() { 1; }",
- CompoundStatement(StatementCountIs(2))));
+ CompoundStatement(statementCountIs(2))));
}
TEST(StatementCountIs, WorksWithMultipleStatements) {
EXPECT_TRUE(matches("void f() { 1; 2; 3; }",
- CompoundStatement(StatementCountIs(3))));
+ CompoundStatement(statementCountIs(3))));
}
TEST(StatementCountIs, WorksWithNestedCompoundStatements) {
EXPECT_TRUE(matches("void f() { { 1; } { 1; 2; 3; 4; } }",
- CompoundStatement(StatementCountIs(1))));
+ CompoundStatement(statementCountIs(1))));
EXPECT_TRUE(matches("void f() { { 1; } { 1; 2; 3; 4; } }",
- CompoundStatement(StatementCountIs(2))));
+ CompoundStatement(statementCountIs(2))));
EXPECT_TRUE(notMatches("void f() { { 1; } { 1; 2; 3; 4; } }",
- CompoundStatement(StatementCountIs(3))));
+ CompoundStatement(statementCountIs(3))));
EXPECT_TRUE(matches("void f() { { 1; } { 1; 2; 3; 4; } }",
- CompoundStatement(StatementCountIs(4))));
+ CompoundStatement(statementCountIs(4))));
}
TEST(Member, WorksInSimplestCase) {
EXPECT_TRUE(matches("struct { int first; } s; int i(s.first);",
- MemberExpression(Member(HasName("first")))));
+ MemberExpression(member(hasName("first")))));
}
TEST(Member, DoesNotMatchTheBaseExpression) {
// Don't pick out the wrong part of the member expression, this should
// be checking the member (name) only.
EXPECT_TRUE(notMatches("struct { int i; } first; int i(first.i);",
- MemberExpression(Member(HasName("first")))));
+ MemberExpression(member(hasName("first")))));
}
TEST(Member, MatchesInMemberFunctionCall) {
@@ -1666,70 +1666,70 @@
" struct { void first() {}; } s;"
" s.first();"
"};",
- MemberExpression(Member(HasName("first")))));
+ MemberExpression(member(hasName("first")))));
}
TEST(HasObjectExpression, DoesNotMatchMember) {
EXPECT_TRUE(notMatches(
"class X {}; struct Z { X m; }; void f(Z z) { z.m; }",
- MemberExpression(HasObjectExpression(HasType(Class(HasName("X")))))));
+ MemberExpression(hasObjectExpression(hasType(Class(hasName("X")))))));
}
TEST(HasObjectExpression, MatchesBaseOfVariable) {
EXPECT_TRUE(matches(
"struct X { int m; }; void f(X x) { x.m; }",
- MemberExpression(HasObjectExpression(HasType(Class(HasName("X")))))));
+ MemberExpression(hasObjectExpression(hasType(Class(hasName("X")))))));
EXPECT_TRUE(matches(
"struct X { int m; }; void f(X* x) { x->m; }",
- MemberExpression(HasObjectExpression(
- HasType(PointsTo(Class(HasName("X"))))))));
+ MemberExpression(hasObjectExpression(
+ hasType(pointsTo(Class(hasName("X"))))))));
}
TEST(HasObjectExpression,
MatchesObjectExpressionOfImplicitlyFormedMemberExpression) {
EXPECT_TRUE(matches(
"class X {}; struct S { X m; void f() { this->m; } };",
- MemberExpression(HasObjectExpression(
- HasType(PointsTo(Class(HasName("S"))))))));
+ MemberExpression(hasObjectExpression(
+ hasType(pointsTo(Class(hasName("S"))))))));
EXPECT_TRUE(matches(
"class X {}; struct S { X m; void f() { m; } };",
- MemberExpression(HasObjectExpression(
- HasType(PointsTo(Class(HasName("S"))))))));
+ MemberExpression(hasObjectExpression(
+ hasType(pointsTo(Class(hasName("S"))))))));
}
TEST(Field, DoesNotMatchNonFieldMembers) {
- EXPECT_TRUE(notMatches("class X { void m(); };", Field(HasName("m"))));
- EXPECT_TRUE(notMatches("class X { class m {}; };", Field(HasName("m"))));
- EXPECT_TRUE(notMatches("class X { enum { m }; };", Field(HasName("m"))));
- EXPECT_TRUE(notMatches("class X { enum m {}; };", Field(HasName("m"))));
+ EXPECT_TRUE(notMatches("class X { void m(); };", Field(hasName("m"))));
+ EXPECT_TRUE(notMatches("class X { class m {}; };", Field(hasName("m"))));
+ EXPECT_TRUE(notMatches("class X { enum { m }; };", Field(hasName("m"))));
+ EXPECT_TRUE(notMatches("class X { enum m {}; };", Field(hasName("m"))));
}
TEST(Field, MatchesField) {
- EXPECT_TRUE(matches("class X { int m; };", Field(HasName("m"))));
+ EXPECT_TRUE(matches("class X { int m; };", Field(hasName("m"))));
}
TEST(IsConstQualified, MatchesConstInt) {
EXPECT_TRUE(matches("const int i = 42;",
- Variable(HasType(IsConstQualified()))));
+ Variable(hasType(isConstQualified()))));
}
TEST(IsConstQualified, MatchesConstPointer) {
EXPECT_TRUE(matches("int i = 42; int* const p(&i);",
- Variable(HasType(IsConstQualified()))));
+ Variable(hasType(isConstQualified()))));
}
TEST(IsConstQualified, MatchesThroughTypedef) {
EXPECT_TRUE(matches("typedef const int const_int; const_int i = 42;",
- Variable(HasType(IsConstQualified()))));
+ Variable(hasType(isConstQualified()))));
EXPECT_TRUE(matches("typedef int* int_ptr; const int_ptr p(0);",
- Variable(HasType(IsConstQualified()))));
+ Variable(hasType(isConstQualified()))));
}
TEST(IsConstQualified, DoesNotMatchInappropriately) {
EXPECT_TRUE(notMatches("typedef int nonconst_int; nonconst_int i = 42;",
- Variable(HasType(IsConstQualified()))));
+ Variable(hasType(isConstQualified()))));
EXPECT_TRUE(notMatches("int const* p;",
- Variable(HasType(IsConstQualified()))));
+ Variable(hasType(isConstQualified()))));
}
TEST(ReinterpretCast, MatchesSimpleCase) {
@@ -1794,15 +1794,15 @@
TEST(HasDestinationType, MatchesSimpleCase) {
EXPECT_TRUE(matches("char* p = static_cast<char*>(0);",
Expression(
- StaticCast(HasDestinationType(
- PointsTo(TypeMatcher(True())))))));
+ StaticCast(hasDestinationType(
+ pointsTo(TypeMatcher(anything())))))));
}
TEST(HasSourceExpression, MatchesSimpleCase) {
EXPECT_TRUE(matches("class string {}; class URL { public: URL(string s); };"
"void r() {string a_string; URL url = a_string; }",
Expression(ImplicitCast(
- HasSourceExpression(ConstructorCall())))));
+ hasSourceExpression(ConstructorCall())))));
}
TEST(Statement, DoesNotMatchDeclarations) {
@@ -1846,40 +1846,40 @@
TEST(HasConditionVariableStatement, DoesNotMatchCondition) {
EXPECT_TRUE(notMatches(
"void x() { if(true) {} }",
- If(HasConditionVariableStatement(DeclarationStatement()))));
+ If(hasConditionVariableStatement(DeclarationStatement()))));
EXPECT_TRUE(notMatches(
"void x() { int x; if((x = 42)) {} }",
- If(HasConditionVariableStatement(DeclarationStatement()))));
+ If(hasConditionVariableStatement(DeclarationStatement()))));
}
TEST(HasConditionVariableStatement, MatchesConditionVariables) {
EXPECT_TRUE(matches(
"void x() { if(int* a = 0) {} }",
- If(HasConditionVariableStatement(DeclarationStatement()))));
+ If(hasConditionVariableStatement(DeclarationStatement()))));
}
TEST(ForEach, BindsOneNode) {
EXPECT_TRUE(matchAndVerifyResultTrue("class C { int x; };",
- Class(HasName("C"), forEach(Id("x", Field(HasName("x"))))),
+ Class(hasName("C"), forEach(id("x", Field(hasName("x"))))),
new VerifyIdIsBoundToDecl<clang::FieldDecl>("x", 1)));
}
TEST(ForEach, BindsMultipleNodes) {
EXPECT_TRUE(matchAndVerifyResultTrue("class C { int x; int y; int z; };",
- Class(HasName("C"), forEach(Id("f", Field()))),
+ Class(hasName("C"), forEach(id("f", Field()))),
new VerifyIdIsBoundToDecl<clang::FieldDecl>("f", 3)));
}
TEST(ForEach, BindsRecursiveCombinations) {
EXPECT_TRUE(matchAndVerifyResultTrue(
"class C { class D { int x; int y; }; class E { int y; int z; }; };",
- Class(HasName("C"), forEach(Class(forEach(Id("f", Field()))))),
+ Class(hasName("C"), forEach(Class(forEach(id("f", Field()))))),
new VerifyIdIsBoundToDecl<clang::FieldDecl>("f", 4)));
}
TEST(ForEachDescendant, BindsOneNode) {
EXPECT_TRUE(matchAndVerifyResultTrue("class C { class D { int x; }; };",
- Class(HasName("C"), forEachDescendant(Id("x", Field(HasName("x"))))),
+ Class(hasName("C"), forEachDescendant(id("x", Field(hasName("x"))))),
new VerifyIdIsBoundToDecl<clang::FieldDecl>("x", 1)));
}
@@ -1887,7 +1887,7 @@
EXPECT_TRUE(matchAndVerifyResultTrue(
"class C { class D { int x; int y; }; "
" class E { class F { int y; int z; }; }; };",
- Class(HasName("C"), forEachDescendant(Id("f", Field()))),
+ Class(hasName("C"), forEachDescendant(id("f", Field()))),
new VerifyIdIsBoundToDecl<clang::FieldDecl>("f", 4)));
}
@@ -1895,8 +1895,8 @@
EXPECT_TRUE(matchAndVerifyResultTrue(
"class C { class D { "
" class E { class F { class G { int y; int z; }; }; }; }; };",
- Class(HasName("C"), forEachDescendant(Class(
- forEachDescendant(Id("f", Field()))))),
+ Class(hasName("C"), forEachDescendant(Class(
+ forEachDescendant(id("f", Field()))))),
new VerifyIdIsBoundToDecl<clang::FieldDecl>("f", 8)));
}
@@ -1907,27 +1907,27 @@
EXPECT_TRUE(matches(
"template <typename T> class X {}; class A {}; X<A> x;",
- Class(HasName("::X"), IsTemplateInstantiation())));
+ Class(hasName("::X"), isTemplateInstantiation())));
EXPECT_TRUE(matches(
"template <typename T> class X { T t; }; class A {}; X<A> x;",
- Class(IsTemplateInstantiation(), hasDescendant(
- Field(HasType(Class(HasName("A"))))))));
+ Class(isTemplateInstantiation(), hasDescendant(
+ Field(hasType(Class(hasName("A"))))))));
}
TEST(IsTemplateInstantiation, MatchesImplicitFunctionTemplateInstantiation) {
EXPECT_TRUE(matches(
"template <typename T> void f(T t) {} class A {}; void g() { f(A()); }",
- Function(HasParameter(0, HasType(Class(HasName("A")))),
- IsTemplateInstantiation())));
+ Function(hasParameter(0, hasType(Class(hasName("A")))),
+ isTemplateInstantiation())));
}
TEST(IsTemplateInstantiation, MatchesExplicitClassTemplateInstantiation) {
EXPECT_TRUE(matches(
"template <typename T> class X { T t; }; class A {};"
"template class X<A>;",
- Class(IsTemplateInstantiation(), hasDescendant(
- Field(HasType(Class(HasName("A"))))))));
+ Class(isTemplateInstantiation(), hasDescendant(
+ Field(hasType(Class(hasName("A"))))))));
}
TEST(IsTemplateInstantiation,
@@ -1935,7 +1935,7 @@
EXPECT_TRUE(matches(
"template <typename T> class X {};"
"template <typename T> class X<T*> {}; class A {}; X<A*> x;",
- Class(HasName("::X"), IsTemplateInstantiation())));
+ Class(hasName("::X"), isTemplateInstantiation())));
}
TEST(IsTemplateInstantiation,
@@ -1946,7 +1946,7 @@
" template <typename U> class Y { U u; };"
" Y<A> y;"
"};",
- Class(HasName("::X::Y"), IsTemplateInstantiation())));
+ Class(hasName("::X::Y"), isTemplateInstantiation())));
}
TEST(IsTemplateInstantiation, DoesNotMatchInstantiationsInsideOfInstantiation) {
@@ -1959,20 +1959,20 @@
" template <typename U> class Y { U u; };"
" Y<T> y;"
"}; X<A> x;",
- Class(HasName("::X<A>::Y"), Not(IsTemplateInstantiation()))));
+ Class(hasName("::X<A>::Y"), unless(isTemplateInstantiation()))));
}
TEST(IsTemplateInstantiation, DoesNotMatchExplicitClassTemplateSpecialization) {
EXPECT_TRUE(notMatches(
"template <typename T> class X {}; class A {};"
"template <> class X<A> {}; X<A> x;",
- Class(HasName("::X"), IsTemplateInstantiation())));
+ Class(hasName("::X"), isTemplateInstantiation())));
}
TEST(IsTemplateInstantiation, DoesNotMatchNonTemplate) {
EXPECT_TRUE(notMatches(
"class A {}; class Y { A a; };",
- Class(IsTemplateInstantiation())));
+ Class(isTemplateInstantiation())));
}
} // end namespace ast_matchers
Modified: cfe/branches/tooling/unittests/ASTMatchers/Dynamic/GenericMatcherTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/unittests/ASTMatchers/Dynamic/GenericMatcherTest.cpp?rev=159535&r1=159534&r2=159535&view=diff
==============================================================================
--- cfe/branches/tooling/unittests/ASTMatchers/Dynamic/GenericMatcherTest.cpp (original)
+++ cfe/branches/tooling/unittests/ASTMatchers/Dynamic/GenericMatcherTest.cpp Mon Jul 2 11:15:56 2012
@@ -16,7 +16,7 @@
namespace dynamic {
namespace {
-testing::AssertionResult MatchesGeneric(const std::string& Code,
+testing::AssertionResult matchesGeneric(const std::string& Code,
const GenericMatcher& Generic) {
if (matches(Code, Generic.getAs<clang::Decl>())) {
return testing::AssertionSuccess();
@@ -31,75 +31,75 @@
}
TEST(GeneicMatcherTest, SingleNode) {
- EXPECT_TRUE(MatchesGeneric("class X {};",
- GenericMatcher(Class(HasName("X")))));
- EXPECT_TRUE(MatchesGeneric("int x;", GenericMatcher(Variable())));
- EXPECT_TRUE(MatchesGeneric("int foo() { return 1 + 1; }",
+ EXPECT_TRUE(matchesGeneric("class X {};",
+ GenericMatcher(Class(hasName("X")))));
+ EXPECT_TRUE(matchesGeneric("int x;", GenericMatcher(Variable())));
+ EXPECT_TRUE(matchesGeneric("int foo() { return 1 + 1; }",
GenericMatcher(Function())));
- EXPECT_FALSE(MatchesGeneric("int x;", GenericMatcher(Function())));
- EXPECT_FALSE(MatchesGeneric("int foo() { return 1 + 1; }",
+ EXPECT_FALSE(matchesGeneric("int x;", GenericMatcher(Function())));
+ EXPECT_FALSE(matchesGeneric("int foo() { return 1 + 1; }",
GenericMatcher(DeclarationReference())));
}
TEST(GeneicMatcherTest, AnyOf) {
- GenericMatcher Generic(Class(HasName("X")));
+ GenericMatcher Generic(Class(hasName("X")));
- EXPECT_TRUE(MatchesGeneric("class X {};", Generic));
- EXPECT_FALSE(MatchesGeneric("int x;", Generic));
- EXPECT_FALSE(MatchesGeneric("int foo() { return 1 + 1; }", Generic));
+ EXPECT_TRUE(matchesGeneric("class X {};", Generic));
+ EXPECT_FALSE(matchesGeneric("int x;", Generic));
+ EXPECT_FALSE(matchesGeneric("int foo() { return 1 + 1; }", Generic));
Generic = GenericMatcher::anyOf(Generic, Variable());
- EXPECT_TRUE(MatchesGeneric("class X {};", Generic));
- EXPECT_TRUE(MatchesGeneric("int x;", Generic));
- EXPECT_FALSE(MatchesGeneric("int foo() { return 1 + 1; }", Generic));
+ EXPECT_TRUE(matchesGeneric("class X {};", Generic));
+ EXPECT_TRUE(matchesGeneric("int x;", Generic));
+ EXPECT_FALSE(matchesGeneric("int foo() { return 1 + 1; }", Generic));
// We can mix different types of matchers (statements and declarations)
Generic = GenericMatcher::anyOf(Generic,
- BinaryOperator(HasOperatorName("+")));
+ BinaryOperator(hasOperatorName("+")));
- EXPECT_TRUE(MatchesGeneric("class X {};", Generic));
- EXPECT_TRUE(MatchesGeneric("int x;", Generic));
- EXPECT_TRUE(MatchesGeneric("int foo() { return 1 + 1; }", Generic));
+ EXPECT_TRUE(matchesGeneric("class X {};", Generic));
+ EXPECT_TRUE(matchesGeneric("int x;", Generic));
+ EXPECT_TRUE(matchesGeneric("int foo() { return 1 + 1; }", Generic));
}
TEST(GeneicMatcherTest, AllOf) {
- GenericMatcher Generic(BinaryOperator(HasOperatorName("+")));
+ GenericMatcher Generic(BinaryOperator(hasOperatorName("+")));
- EXPECT_TRUE(MatchesGeneric("int i = 1 + 1;", Generic));
- EXPECT_TRUE(MatchesGeneric("int i = 2 + 1;", Generic));
- EXPECT_TRUE(MatchesGeneric("int i = 1 + 3;", Generic));
- EXPECT_FALSE(MatchesGeneric("void foo() { }", Generic));
+ EXPECT_TRUE(matchesGeneric("int i = 1 + 1;", Generic));
+ EXPECT_TRUE(matchesGeneric("int i = 2 + 1;", Generic));
+ EXPECT_TRUE(matchesGeneric("int i = 1 + 3;", Generic));
+ EXPECT_FALSE(matchesGeneric("void foo() { }", Generic));
Generic = GenericMatcher::allOf(
Generic,
- BinaryOperator(HasLHS(IntegerLiteral(Equals(1)))));
+ BinaryOperator(hasLHS(IntegerLiteral(equals(1)))));
- EXPECT_TRUE( MatchesGeneric("int i = 1 + 1;", Generic));
- EXPECT_FALSE(MatchesGeneric("int i = 2 + 1;", Generic));
- EXPECT_TRUE( MatchesGeneric("int i = 1 + 3;", Generic));
- EXPECT_FALSE(MatchesGeneric("void foo() { }", Generic));
+ EXPECT_TRUE( matchesGeneric("int i = 1 + 1;", Generic));
+ EXPECT_FALSE(matchesGeneric("int i = 2 + 1;", Generic));
+ EXPECT_TRUE( matchesGeneric("int i = 1 + 3;", Generic));
+ EXPECT_FALSE(matchesGeneric("void foo() { }", Generic));
Generic = GenericMatcher::allOf(
Generic,
- BinaryOperator(HasRHS(IntegerLiteral(Equals(3)))));
+ BinaryOperator(hasRHS(IntegerLiteral(equals(3)))));
- EXPECT_FALSE(MatchesGeneric("int i = 1 + 1;", Generic));
- EXPECT_FALSE(MatchesGeneric("int i = 2 + 1;", Generic));
- EXPECT_TRUE( MatchesGeneric("int i = 1 + 3;", Generic));
- EXPECT_FALSE(MatchesGeneric("void foo() { }", Generic));
+ EXPECT_FALSE(matchesGeneric("int i = 1 + 1;", Generic));
+ EXPECT_FALSE(matchesGeneric("int i = 2 + 1;", Generic));
+ EXPECT_TRUE( matchesGeneric("int i = 1 + 3;", Generic));
+ EXPECT_FALSE(matchesGeneric("void foo() { }", Generic));
Generic = GenericMatcher::allOf(Generic, Function());
// Now nothing matches. Not even the function one because it is an AllOf().
- EXPECT_FALSE(MatchesGeneric("int i = 1 + 1;", Generic));
- EXPECT_FALSE(MatchesGeneric("int i = 2 + 1;", Generic));
- EXPECT_FALSE(MatchesGeneric("int i = 1 + 3;", Generic));
- EXPECT_FALSE(MatchesGeneric("void foo() { }", Generic));
+ EXPECT_FALSE(matchesGeneric("int i = 1 + 1;", Generic));
+ EXPECT_FALSE(matchesGeneric("int i = 2 + 1;", Generic));
+ EXPECT_FALSE(matchesGeneric("int i = 1 + 3;", Generic));
+ EXPECT_FALSE(matchesGeneric("void foo() { }", Generic));
// Still no match, because it has to match all of it on the same node.
- EXPECT_FALSE(MatchesGeneric("int foo() { return 1 + 3; }", Generic));
+ EXPECT_FALSE(matchesGeneric("int foo() { return 1 + 3; }", Generic));
}
} // end anonymous namespace
Modified: cfe/branches/tooling/unittests/ASTMatchers/Dynamic/ParserTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/unittests/ASTMatchers/Dynamic/ParserTest.cpp?rev=159535&r1=159534&r2=159535&view=diff
==============================================================================
--- cfe/branches/tooling/unittests/ASTMatchers/Dynamic/ParserTest.cpp (original)
+++ cfe/branches/tooling/unittests/ASTMatchers/Dynamic/ParserTest.cpp Mon Jul 2 11:15:56 2012
@@ -24,7 +24,7 @@
public:
virtual ~ValueProcessor() { }
- void Parse(const std::string& Code) {
+ void parse(const std::string& Code) {
const GenericValue Value = Parser::parseMatcher(Code, this);
if (Value.is<GenericError>()) {
ValueInfo ToStore = { Value, Parser::TokenInfo() };
@@ -65,10 +65,10 @@
TEST(ParserTest, ParseString) {
ValueProcessor Processor;
- Processor.Parse("\"Foo\"");
- Processor.Parse("\"F\\\"o o\\n\"");
- Processor.Parse("\"\"");
- Processor.Parse("\"Baz");
+ Processor.parse("\"Foo\"");
+ Processor.parse("\"F\\\"o o\\n\"");
+ Processor.parse("\"\"");
+ Processor.parse("\"Baz");
EXPECT_EQ(4ULL, Processor.Values.size());
EXPECT_EQ("Foo", Processor.Values[0].Value.get<std::string>());
EXPECT_EQ("F\"o o\n", Processor.Values[1].Value.get<std::string>());
@@ -79,13 +79,13 @@
TEST(ParserTest, ParseChar) {
ValueProcessor Processor;
- Processor.Parse("'a'");
- Processor.Parse("'^'");
- Processor.Parse("'\\n'");
- Processor.Parse("'aa'");
- Processor.Parse("'6");
- Processor.Parse("' '");
- Processor.Parse("','");
+ Processor.parse("'a'");
+ Processor.parse("'^'");
+ Processor.parse("'\\n'");
+ Processor.parse("'aa'");
+ Processor.parse("'6");
+ Processor.parse("' '");
+ Processor.parse("','");
EXPECT_EQ(7ULL, Processor.Values.size());
EXPECT_EQ('a', Processor.Values[0].Value.get<int>());
EXPECT_EQ('^', Processor.Values[1].Value.get<int>());
@@ -100,12 +100,12 @@
TEST(ParserTest, ParseNumber) {
ValueProcessor Processor;
- Processor.Parse("123456789012345");
- Processor.Parse("-1234567890123456");
- Processor.Parse("1.23e5");
- Processor.Parse("1.234e-5");
- Processor.Parse("0x5");
- Processor.Parse("0d3jg#");
+ Processor.parse("123456789012345");
+ Processor.parse("-1234567890123456");
+ Processor.parse("1.23e5");
+ Processor.parse("1.234e-5");
+ Processor.parse("0x5");
+ Processor.parse("0d3jg#");
EXPECT_EQ(6ULL, Processor.Values.size());
EXPECT_EQ(123456789012345ULL, Processor.Values[0].Value.get<uint64_t>());
EXPECT_EQ(-1234567890123456LL, Processor.Values[1].Value.get<int64_t>());
@@ -118,14 +118,14 @@
TEST(ParserTest, ParseBool) {
ValueProcessor Processor;
- Processor.Parse("true");
- Processor.Parse("false");
+ Processor.parse("true");
+ Processor.parse("false");
EXPECT_EQ(2UL, Processor.Values.size());
EXPECT_EQ(true, Processor.Values[0].Value.get<bool>());
EXPECT_EQ(false, Processor.Values[1].Value.get<bool>());
}
-bool MatchesInfo(const Parser::TokenInfo& Info,
+bool matchesInfo(const Parser::TokenInfo& Info,
int StartLine, int EndLine, int StartColumn, int EndColumn) {
EXPECT_EQ(StartLine, Info.StartLine);
EXPECT_EQ(EndLine, Info.EndLine);
@@ -137,7 +137,7 @@
TEST(ParserTest, ParseMatcher) {
ValueProcessor Processor;
- Processor.Parse(" Foo ( 1.2, Bar (), Baz( \n \"B \\nA,\\\"Z\"), \ntrue) ");
+ Processor.parse(" Foo ( 1.2, Bar (), Baz( \n \"B \\nA,\\\"Z\"), \ntrue) ");
for (size_t i = 0; i < Processor.Values.size(); ++i) {
EXPECT_FALSE(Processor.Values[i].Value.is<GenericError>())
<< Processor.Values[i].Value.get<GenericError>().Message;
@@ -146,18 +146,18 @@
EXPECT_EQ(3ULL, Processor.Matchers.size());
const ValueProcessor::MatcherInfo Bar = Processor.Matchers[0];
EXPECT_EQ("Bar", Bar.MatcherName);
- EXPECT_TRUE(MatchesInfo(Bar.Info, 1, 1, 13, 18));
+ EXPECT_TRUE(matchesInfo(Bar.Info, 1, 1, 13, 18));
EXPECT_EQ(0ULL, Bar.Args.size());
const ValueProcessor::MatcherInfo Baz = Processor.Matchers[1];
EXPECT_EQ("Baz", Baz.MatcherName);
- EXPECT_TRUE(MatchesInfo(Baz.Info, 1, 2, 21, 13));
+ EXPECT_TRUE(matchesInfo(Baz.Info, 1, 2, 21, 13));
EXPECT_EQ(1ULL, Baz.Args.size());
EXPECT_EQ("B \nA,\"Z", Baz.Args[0].get<std::string>());
const ValueProcessor::MatcherInfo Foo = Processor.Matchers[2];
EXPECT_EQ("Foo", Foo.MatcherName);
- EXPECT_TRUE(MatchesInfo(Foo.Info, 1, 3, 2, 5));
+ EXPECT_TRUE(matchesInfo(Foo.Info, 1, 3, 2, 5));
EXPECT_EQ(4ULL, Foo.Args.size());
EXPECT_EQ(1.2, Foo.Args[0].get<double>());
EXPECT_EQ("__Bar__", Foo.Args[1].get<std::string>());
@@ -175,7 +175,7 @@
}
};
-testing::AssertionResult MatchesGeneric(const std::string& Code,
+testing::AssertionResult matchesGeneric(const std::string& Code,
const GenericValue& Value) {
if (!Value.is<GenericMatcher>())
return testing::AssertionFailure();
@@ -197,8 +197,8 @@
const GenericValue Value = Parser::parseMatcher(
"BinaryOperator( HasOperatorName(\"+\"),\n"
" HasLHS(IntegerLiteral(Equals(1))))", &Processor);
- EXPECT_TRUE(MatchesGeneric("int x = 1 + 1;", Value));
- EXPECT_FALSE(MatchesGeneric("int x = 2 + 1;", Value));
+ EXPECT_TRUE(matchesGeneric("int x = 1 + 1;", Value));
+ EXPECT_FALSE(matchesGeneric("int x = 2 + 1;", Value));
const GenericValue Error = Parser::parseMatcher(
"BinaryOperator( HasOperatorName(6),\n"
Modified: cfe/branches/tooling/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/unittests/ASTMatchers/Dynamic/RegistryTest.cpp?rev=159535&r1=159534&r2=159535&view=diff
==============================================================================
--- cfe/branches/tooling/unittests/ASTMatchers/Dynamic/RegistryTest.cpp (original)
+++ cfe/branches/tooling/unittests/ASTMatchers/Dynamic/RegistryTest.cpp Mon Jul 2 11:15:56 2012
@@ -18,7 +18,7 @@
namespace dynamic {
namespace {
-testing::AssertionResult MatchesGeneric(const std::string& Code,
+testing::AssertionResult matchesGeneric(const std::string& Code,
const GenericValue& Value) {
if (Value.is<GenericError>()) {
EXPECT_EQ("", Value.get<GenericError>().Message);
@@ -37,19 +37,19 @@
return testing::AssertionFailure();
}
-GenericValue ConstructMatcher(const std::string& MatcherName) {
+GenericValue constructMatcher(const std::string& MatcherName) {
const std::vector<GenericValue> Args;
return Registry::constructMatcher(MatcherName, Args);
}
-GenericValue ConstructMatcher(const std::string& MatcherName,
+GenericValue constructMatcher(const std::string& MatcherName,
const GenericValue Arg1) {
std::vector<GenericValue> Args;
Args.push_back(Arg1);
return Registry::constructMatcher(MatcherName, Args);
}
-GenericValue ConstructMatcher(const std::string& MatcherName,
+GenericValue constructMatcher(const std::string& MatcherName,
const GenericValue Arg1,
const GenericValue Arg2) {
std::vector<GenericValue> Args;
@@ -59,8 +59,8 @@
}
TEST(RegistryTest, CanConstructNoArgs) {
- const GenericValue IsArrowValue = ConstructMatcher("IsArrow");
- const GenericValue BoolValue = ConstructMatcher("BoolLiteral");
+ const GenericValue IsArrowValue = constructMatcher("IsArrow");
+ const GenericValue BoolValue = constructMatcher("BoolLiteral");
const std::string ClassSnippet =
"struct Foo { int x; };\n"
@@ -68,69 +68,69 @@
"int i = foo->x;\n";
const std::string BoolSnippet = "bool Foo = true;\n";
- EXPECT_TRUE(MatchesGeneric(ClassSnippet, IsArrowValue));
- EXPECT_TRUE(MatchesGeneric(BoolSnippet, BoolValue));
- EXPECT_FALSE(MatchesGeneric(ClassSnippet, BoolValue));
- EXPECT_FALSE(MatchesGeneric(BoolSnippet, IsArrowValue));
+ EXPECT_TRUE(matchesGeneric(ClassSnippet, IsArrowValue));
+ EXPECT_TRUE(matchesGeneric(BoolSnippet, BoolValue));
+ EXPECT_FALSE(matchesGeneric(ClassSnippet, BoolValue));
+ EXPECT_FALSE(matchesGeneric(BoolSnippet, IsArrowValue));
}
TEST(RegistryTest, ConstructWithSimpleArgs) {
- const GenericValue Value = ConstructMatcher("HasName", std::string("X"));
- EXPECT_TRUE(MatchesGeneric("class X {};", Value));
- EXPECT_FALSE(MatchesGeneric("int x;", Value));
+ const GenericValue Value = constructMatcher("HasName", std::string("X"));
+ EXPECT_TRUE(matchesGeneric("class X {};", Value));
+ EXPECT_FALSE(matchesGeneric("int x;", Value));
}
TEST(RegistryTest, ContructWithMatcherArgs) {
const GenericValue OperatorPlus =
- ConstructMatcher("HasOperatorName", std::string("+"));
+ constructMatcher("HasOperatorName", std::string("+"));
const GenericValue OperatorMinus =
- ConstructMatcher("HasOperatorName", std::string("-"));
+ constructMatcher("HasOperatorName", std::string("-"));
const GenericValue One =
- ConstructMatcher("IntegerLiteral", ConstructMatcher("Equals", 1));
- const GenericValue HasLHSOne = ConstructMatcher("HasLHS", One);
+ constructMatcher("IntegerLiteral", constructMatcher("Equals", 1));
+ const GenericValue HasLHSOne = constructMatcher("HasLHS", One);
const GenericValue OnePlus =
- ConstructMatcher("BinaryOperator", OperatorPlus, HasLHSOne);
+ constructMatcher("BinaryOperator", OperatorPlus, HasLHSOne);
const GenericValue JustPlus =
- ConstructMatcher("BinaryOperator", OperatorPlus);
+ constructMatcher("BinaryOperator", OperatorPlus);
const GenericValue OneMinus =
- ConstructMatcher("BinaryOperator", OperatorMinus, HasLHSOne);
+ constructMatcher("BinaryOperator", OperatorMinus, HasLHSOne);
const GenericValue JustMinus =
- ConstructMatcher("BinaryOperator", OperatorMinus);
+ constructMatcher("BinaryOperator", OperatorMinus);
- EXPECT_TRUE( MatchesGeneric("int i = 1 + 1;", OnePlus));
- EXPECT_TRUE( MatchesGeneric("int i = 1 + 1;", JustPlus));
- EXPECT_FALSE(MatchesGeneric("int i = 1 + 1;", OneMinus));
- EXPECT_FALSE(MatchesGeneric("int i = 1 + 1;", JustMinus));
-
- EXPECT_FALSE(MatchesGeneric("int i = 1 - 1;", OnePlus));
- EXPECT_FALSE(MatchesGeneric("int i = 1 - 1;", JustPlus));
- EXPECT_TRUE( MatchesGeneric("int i = 1 - 1;", OneMinus));
- EXPECT_TRUE( MatchesGeneric("int i = 1 - 1;", JustMinus));
-
- EXPECT_FALSE(MatchesGeneric("int i = 2 + 1;", OnePlus));
- EXPECT_TRUE( MatchesGeneric("int i = 2 + 1;", JustPlus));
- EXPECT_FALSE(MatchesGeneric("int i = 2 + 1;", OneMinus));
- EXPECT_FALSE(MatchesGeneric("int i = 2 + 1;", JustMinus));
+ EXPECT_TRUE( matchesGeneric("int i = 1 + 1;", OnePlus));
+ EXPECT_TRUE( matchesGeneric("int i = 1 + 1;", JustPlus));
+ EXPECT_FALSE(matchesGeneric("int i = 1 + 1;", OneMinus));
+ EXPECT_FALSE(matchesGeneric("int i = 1 + 1;", JustMinus));
+
+ EXPECT_FALSE(matchesGeneric("int i = 1 - 1;", OnePlus));
+ EXPECT_FALSE(matchesGeneric("int i = 1 - 1;", JustPlus));
+ EXPECT_TRUE( matchesGeneric("int i = 1 - 1;", OneMinus));
+ EXPECT_TRUE( matchesGeneric("int i = 1 - 1;", JustMinus));
+
+ EXPECT_FALSE(matchesGeneric("int i = 2 + 1;", OnePlus));
+ EXPECT_TRUE( matchesGeneric("int i = 2 + 1;", JustPlus));
+ EXPECT_FALSE(matchesGeneric("int i = 2 + 1;", OneMinus));
+ EXPECT_FALSE(matchesGeneric("int i = 2 + 1;", JustMinus));
}
TEST(RegistryTest, Errors) {
// Incorrect argument count.
- GenericValue BadArgCount = ConstructMatcher("HasBody");
+ GenericValue BadArgCount = constructMatcher("HasBody");
EXPECT_EQ("Incorrect argument count on function HasBody. "
"(Expected = 1) != (Actual = 0)",
BadArgCount.get<GenericError>().Message);
- BadArgCount = ConstructMatcher("IsArrow", std::string());
+ BadArgCount = constructMatcher("IsArrow", std::string());
EXPECT_EQ("Incorrect argument count on function IsArrow. "
"(Expected = 0) != (Actual = 1)",
BadArgCount.get<GenericError>().Message);
// Bad argument type
- GenericValue BadArgType = ConstructMatcher("OfClass", true);
+ GenericValue BadArgType = constructMatcher("OfClass", true);
EXPECT_EQ("Incorrect type on function OfClass for arg 0",
BadArgType.get<GenericError>().Message);
- BadArgType = ConstructMatcher("Class", Class(), 3);
+ BadArgType = constructMatcher("Class", Class(), 3);
EXPECT_EQ("Incorrect type on function Class for arg 1",
BadArgType.get<GenericError>().Message);
}
More information about the llvm-branch-commits
mailing list