r209006 - [ASTMatchers] Move the 'isImplicit' matcher from CXXConstructorDecl to Decl.
Joey Gouly
joey.gouly at gmail.com
Fri May 16 12:31:08 PDT 2014
Author: joey
Date: Fri May 16 14:31:08 2014
New Revision: 209006
URL: http://llvm.org/viewvc/llvm-project?rev=209006&view=rev
Log:
[ASTMatchers] Move the 'isImplicit' matcher from CXXConstructorDecl to Decl.
Modified:
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=209006&r1=209005&r2=209006&view=diff
==============================================================================
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Fri May 16 14:31:08 2014
@@ -311,6 +311,12 @@ AST_MATCHER(Decl, isPrivate) {
return Node.getAccess() == AS_private;
}
+/// \brief Matches a declaration that has been implicitly added
+/// by the compiler (eg. implicit default/copy constructors).
+AST_MATCHER(Decl, isImplicit) {
+ return Node.isImplicit();
+}
+
/// \brief Matches classTemplateSpecializations that have at least one
/// TemplateArgument matching the given InnerMatcher.
///
@@ -2187,12 +2193,6 @@ AST_MATCHER(CXXCtorInitializer, isWritte
return Node.isWritten();
}
-/// \brief Matches a constructor declaration that has been implicitly added
-/// by the compiler (eg. implicit default/copy constructors).
-AST_MATCHER(CXXConstructorDecl, isImplicit) {
- return Node.isImplicit();
-}
-
/// \brief Matches any argument of a call expression or a constructor call
/// expression.
///
Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=209006&r1=209005&r2=209006&view=diff
==============================================================================
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Fri May 16 14:31:08 2014
@@ -1773,6 +1773,9 @@ TEST(ConstructorDeclaration, IsImplicit)
constructorDecl(isImplicit())));
EXPECT_TRUE(matches("class Foo { Foo(){} };",
constructorDecl(unless(isImplicit()))));
+ // The compiler added an implicit assignment operator.
+ EXPECT_TRUE(matches("struct A { int x; } a = {0}, b = a; void f() { a = b; }",
+ methodDecl(isImplicit(), hasName("operator="))));
}
TEST(DestructorDeclaration, MatchesVirtualDestructor) {
More information about the cfe-commits
mailing list