[PATCH] [ASTMatchers] Allow isImplicit on all Decls.
Joey Gouly
joey.gouly at gmail.com
Thu May 15 14:19:37 PDT 2014
Fixed the comment! Ok now?
http://reviews.llvm.org/D3775
Files:
include/clang/ASTMatchers/ASTMatchers.h
unittests/ASTMatchers/ASTMatchersTest.cpp
Index: include/clang/ASTMatchers/ASTMatchers.h
===================================================================
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -311,6 +311,12 @@
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 @@
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.
///
Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===================================================================
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -1773,6 +1773,9 @@
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) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3775.9456.patch
Type: text/x-patch
Size: 1648 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140515/4561379b/attachment.bin>
More information about the cfe-commits
mailing list