summaryrefslogtreecommitdiffstats
path: root/clang/include
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
commitf901b719214d0bd4d42d85e9b5bbbc95d1ee3479 (patch)
tree662b1c8fc2a683ef80574b64b891f01f92ab435b /clang/include
parented936457393fa19d86bd9223f815b8cead44e20d (diff)
downloadbcm5719-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/include')
-rw-r--r--clang/include/clang/ASTMatchers/ASTMatchers.h18
-rw-r--r--clang/include/clang/ASTMatchers/ASTMatchersInternal.h9
2 files changed, 26 insertions, 1 deletions
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 443c628519a..bee7c214355 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -1629,7 +1629,8 @@ unless(const M &InnerMatcher) {
/// subtypes of clang::Type.
///
/// Usable as: Matcher<QualType>, Matcher<CallExpr>, Matcher<CXXConstructExpr>,
-/// Matcher<MemberExpr>, Matcher<TypedefType>
+/// Matcher<MemberExpr>, Matcher<TypedefType>,
+/// Matcher<TemplateSpecializationType>
inline internal::PolymorphicMatcherWithParam1< internal::HasDeclarationMatcher,
internal::Matcher<Decl> >
hasDeclaration(const internal::Matcher<Decl> &InnerMatcher) {
@@ -2913,6 +2914,21 @@ AST_TYPELOC_TRAVERSE_MATCHER(pointee, getPointee);
/// matches "typedef int X"
AST_TYPE_MATCHER(TypedefType, typedefType);
+/// \brief Matches template specialization types.
+///
+/// Given
+/// \code
+/// template <typename T>
+/// class C { };
+///
+/// template class C<int>; // A
+/// C<char> var; // B
+/// \code
+///
+/// \c templateSpecializationType() matches the type of the explicit
+/// instantiation in \c A and the type of the variable declaration in \c B.
+AST_TYPE_MATCHER(TemplateSpecializationType, templateSpecializationType);
+
/// \brief Matches nested name specifiers.
///
/// Given
diff --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index ac85f501072..1119a72a425 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -411,6 +411,15 @@ private:
return matchesDecl(Node->getAsCXXRecordDecl(), Finder, Builder);
}
+ /// \brief Gets the TemplateDecl from a TemplateSpecializationType
+ /// and returns whether the inner matches on it.
+ bool matchesSpecialized(const TemplateSpecializationType &Node,
+ ASTMatchFinder *Finder,
+ BoundNodesTreeBuilder *Builder) const {
+ return matchesDecl(Node.getTemplateName().getAsTemplateDecl(),
+ Finder, Builder);
+ }
+
/// \brief Extracts the Decl of the callee of a CallExpr and returns whether
/// the inner matcher matches on it.
bool matchesSpecialized(const CallExpr &Node, ASTMatchFinder *Finder,
OpenPOWER on IntegriCloud