diff options
author | Edwin Vane <edwin.vane@intel.com> | 2013-02-25 14:49:29 +0000 |
---|---|---|
committer | Edwin Vane <edwin.vane@intel.com> | 2013-02-25 14:49:29 +0000 |
commit | f901b719214d0bd4d42d85e9b5bbbc95d1ee3479 (patch) | |
tree | 662b1c8fc2a683ef80574b64b891f01f92ab435b /clang/unittests/ASTMatchers/ASTMatchersTest.cpp | |
parent | ed936457393fa19d86bd9223f815b8cead44e20d (diff) | |
download | bcm5719-llvm-f901b719214d0bd4d42d85e9b5bbbc95d1ee3479.tar.gz bcm5719-llvm-f901b719214d0bd4d42d85e9b5bbbc95d1ee3479.zip |
Adding hasDeclaration overload for TemplateSpecializationType
TemplateSpecializationType doesn't quite have getDecl(). Need to go
through TemplateName to get a TemplateDecl.
Added test cases for the hasDeclaration() overload for
TemplateSpecializationType. Also introduced the type matcher
templateSpecializationType() used by the new hasDeclaration() test case.
Updated LibASTMatchersReference.
Reviewers: klimek
llvm-svn: 176025
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersTest.cpp')
-rw-r--r-- | clang/unittests/ASTMatchers/ASTMatchersTest.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp index a759df9070f..6eb552aa564 100644 --- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp @@ -832,6 +832,12 @@ TEST(HasDeclaration, HasDeclarationOfTypeWithDecl) { // FIXME: Add tests for other types with getDecl() (e.g. RecordType) } +TEST(HasDeclaration, HasDeclarationOfTemplateSpecializationType) { + EXPECT_TRUE(matches("template <typename T> class A {}; A<int> a;", + varDecl(hasType(templateSpecializationType( + hasDeclaration(namedDecl(hasName("A")))))))); +} + TEST(HasType, TakesQualTypeMatcherAndMatchesExpr) { TypeMatcher ClassX = hasDeclaration(recordDecl(hasName("X"))); EXPECT_TRUE( @@ -3406,6 +3412,11 @@ TEST(TypeMatching, MatchesTypedefTypes) { hasType(typedefType())))); } +TEST(TypeMatching, MatchesTemplateSpecializationType) { + EXPECT_TRUE(matches("template <typename T> class A{}; A<int>a;", + templateSpecializationType())); +} + TEST(NNS, MatchesNestedNameSpecifiers) { EXPECT_TRUE(matches("namespace ns { struct A {}; } ns::A a;", nestedNameSpecifier())); |