aboutsummaryrefslogtreecommitdiff
path: root/unittests/ASTMatchers/ASTMatchersTest.cpp
diff options
context:
space:
mode:
authorEdwin Vane <edwin.vane@intel.com>2013-02-25 14:49:29 +0000
committerEdwin Vane <edwin.vane@intel.com>2013-02-25 14:49:29 +0000
commit3abf77872ca6c520903f9174cf6cd89a50df2714 (patch)
tree6efcd46148dbf526dc06f3ae18aa3bb6d2d2f2cc /unittests/ASTMatchers/ASTMatchersTest.cpp
parentb45083d08377a8b9528401fdafd7210e78895dbe (diff)
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176025 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/ASTMatchers/ASTMatchersTest.cpp')
-rw-r--r--unittests/ASTMatchers/ASTMatchersTest.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/unittests/ASTMatchers/ASTMatchersTest.cpp b/unittests/ASTMatchers/ASTMatchersTest.cpp
index a759df9070..6eb552aa56 100644
--- a/unittests/ASTMatchers/ASTMatchersTest.cpp
+++ b/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()));