diff options
author | Edwin Vane <edwin.vane@intel.com> | 2013-02-19 17:14:34 +0000 |
---|---|---|
committer | Edwin Vane <edwin.vane@intel.com> | 2013-02-19 17:14:34 +0000 |
commit | 2c197e09397ee071c678ba77c2451166264b55f7 (patch) | |
tree | 44ab43b33501f733618bd7aa7c9d73f02785c67b /clang/unittests/ASTMatchers/ASTMatchersTest.cpp | |
parent | 1c040b57885e360149b2d3cf317570a3a6effa08 (diff) | |
download | bcm5719-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.cpp | 12 |
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) { |