diff options
author | Malcolm Parsons <malcolm.parsons@gmail.com> | 2016-10-31 22:04:07 +0000 |
---|---|---|
committer | Malcolm Parsons <malcolm.parsons@gmail.com> | 2016-10-31 22:04:07 +0000 |
commit | cc21152c21d1ba222e796b904eab8640e720df3c (patch) | |
tree | 606fe0f5db96df669f4d07b39752d4e0a269493b /include/clang/ASTMatchers | |
parent | 2a210ccdfe2933df58096e10e94d6faa6e0585e6 (diff) |
[ASTMatcher] Add CXXNewExpr support to hasDeclaration
Reviewers: sbenza, lukasza, aaron.ballman, klimek
Subscribers: lukasza, sbenza, cfe-commits
Differential Revision: https://reviews.llvm.org/D26032
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@285644 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/ASTMatchers')
-rw-r--r-- | include/clang/ASTMatchers/ASTMatchers.h | 14 | ||||
-rw-r--r-- | include/clang/ASTMatchers/ASTMatchersInternal.h | 14 |
2 files changed, 19 insertions, 9 deletions
diff --git a/include/clang/ASTMatchers/ASTMatchers.h b/include/clang/ASTMatchers/ASTMatchers.h index 3c001c554e..fa68fab58b 100644 --- a/include/clang/ASTMatchers/ASTMatchers.h +++ b/include/clang/ASTMatchers/ASTMatchers.h @@ -2450,16 +2450,18 @@ const internal::VariadicOperatorMatcherFunc<1, 1> unless = { /// - for CallExpr, the declaration of the callee /// - for MemberExpr, the declaration of the referenced member /// - for CXXConstructExpr, the declaration of the constructor +/// - for CXXNewExpr, the declaration of the operator new /// /// Also usable as Matcher<T> for any T supporting the getDecl() member /// function. e.g. various subtypes of clang::Type and various expressions. /// -/// Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>, -/// Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, -/// Matcher<LabelStmt>, Matcher<AddrLabelExpr>, Matcher<MemberExpr>, -/// Matcher<QualType>, Matcher<RecordType>, Matcher<TagType>, -/// Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>, -/// Matcher<TypedefType>, Matcher<UnresolvedUsingType> +/// Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>, +/// Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>, +/// Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, +/// Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, +/// Matcher<TagType>, Matcher<TemplateSpecializationType>, +/// Matcher<TemplateTypeParmType>, Matcher<TypedefType>, +/// Matcher<UnresolvedUsingType> inline internal::PolymorphicMatcherWithParam1< internal::HasDeclarationMatcher, internal::Matcher<Decl>, void(internal::HasDeclarationSupportedTypes)> diff --git a/include/clang/ASTMatchers/ASTMatchersInternal.h b/include/clang/ASTMatchers/ASTMatchersInternal.h index b9e3157707..547e6bc486 100644 --- a/include/clang/ASTMatchers/ASTMatchersInternal.h +++ b/include/clang/ASTMatchers/ASTMatchersInternal.h @@ -787,6 +787,14 @@ private: return matchesDecl(Node.getConstructor(), Finder, Builder); } + /// \brief Extracts the operator new of the new call and returns whether the + /// inner matcher matches on it. + bool matchesSpecialized(const CXXNewExpr &Node, + ASTMatchFinder *Finder, + BoundNodesTreeBuilder *Builder) const { + return matchesDecl(Node.getOperatorNew(), Finder, Builder); + } + /// \brief Extracts the \c ValueDecl a \c MemberExpr refers to and returns /// whether the inner matcher matches on it. bool matchesSpecialized(const MemberExpr &Node, @@ -1007,11 +1015,11 @@ typedef TypeList<Decl, Stmt, NestedNameSpecifier, NestedNameSpecifierLoc, TypeLoc, QualType> AdaptativeDefaultToTypes; /// \brief All types that are supported by HasDeclarationMatcher above. -typedef TypeList<CallExpr, CXXConstructExpr, DeclRefExpr, EnumType, +typedef TypeList<CallExpr, CXXConstructExpr, CXXNewExpr, DeclRefExpr, EnumType, InjectedClassNameType, LabelStmt, AddrLabelExpr, MemberExpr, QualType, RecordType, TagType, TemplateSpecializationType, - TemplateTypeParmType, TypedefType, - UnresolvedUsingType> HasDeclarationSupportedTypes; + TemplateTypeParmType, TypedefType, UnresolvedUsingType> + HasDeclarationSupportedTypes; /// \brief Converts a \c Matcher<T> to a matcher of desired type \c To by /// "adapting" a \c To into a \c T. |