summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
diff options
context:
space:
mode:
authorEdwin Vane <edwin.vane@intel.com>2013-02-19 17:14:34 +0000
committerEdwin Vane <edwin.vane@intel.com>2013-02-19 17:14:34 +0000
commit2c197e09397ee071c678ba77c2451166264b55f7 (patch)
tree44ab43b33501f733618bd7aa7c9d73f02785c67b /clang/unittests/ASTMatchers/ASTMatchersTest.cpp
parent1c040b57885e360149b2d3cf317570a3a6effa08 (diff)
downloadbcm5719-llvm-2c197e09397ee071c678ba77c2451166264b55f7.tar.gz
bcm5719-llvm-2c197e09397ee071c678ba77c2451166264b55f7.zip
Support in hasDeclaration for types with getDecl()
Using a new metafunction for detecting the presence of the member 'getDecl' in a type T, added support to hasDeclaration for any such type T. This allows hasDecl() to be replaced and enables several other subclasses of clang::Type to use hasDeclaration. Updated unittests and LibASTMatchersReference.html. Reviewers: klimek llvm-svn: 175532
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersTest.cpp')
-rw-r--r--clang/unittests/ASTMatchers/ASTMatchersTest.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
index 608e7479a6b..8e4f3e93274 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -818,6 +818,14 @@ TEST(HasDeclaration, HasDeclarationOfEnumType) {
qualType(hasDeclaration(enumDecl(hasName("X")))))))));
}
+TEST(HasDeclaration, HasDeclarationOfTypeWithDecl) {
+ EXPECT_TRUE(matches("typedef int X; X a;",
+ varDecl(hasName("a"),
+ hasType(typedefType(hasDeclaration(decl()))))));
+
+ // FIXME: Add tests for other types with getDecl() (e.g. RecordType)
+}
+
TEST(HasType, TakesQualTypeMatcherAndMatchesExpr) {
TypeMatcher ClassX = hasDeclaration(recordDecl(hasName("X")));
EXPECT_TRUE(
@@ -3350,10 +3358,6 @@ TEST(TypeMatching, MatchesPointersToConstTypes) {
TEST(TypeMatching, MatchesTypedefTypes) {
EXPECT_TRUE(matches("typedef int X; X a;", varDecl(hasName("a"),
hasType(typedefType()))));
-
- EXPECT_TRUE(matches("typedef int X; X a;",
- varDecl(hasName("a"),
- hasType(typedefType(hasDecl(decl()))))));
}
TEST(NNS, MatchesNestedNameSpecifiers) {
OpenPOWER on IntegriCloud