From e1f4ba85e5c206011b316d3fc571eb8e7a9510c6 Mon Sep 17 00:00:00 2001 From: Gauthier Harnisch Date: Wed, 19 Jun 2019 18:27:56 +0000 Subject: [clang] Adapt ASTMatcher to explicit(bool) specifier Summary: Changes: - add an ast matcher for deductiong guide. - allow isExplicit matcher for deductiong guide. - add hasExplicitSpecifier matcher which give access to the expression of the explicit specifier if present. Reviewers: klimek, rsmith, aaron.ballman Reviewed By: aaron.ballman Subscribers: aaron.ballman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61552 llvm-svn: 363855 --- clang/docs/LibASTMatchersReference.html | 85 ++++++++++++++++++++++++++++++--- 1 file changed, 79 insertions(+), 6 deletions(-) (limited to 'clang/docs/LibASTMatchersReference.html') diff --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html index 47f2c8a489e..c93394096f2 100644 --- a/clang/docs/LibASTMatchersReference.html +++ b/clang/docs/LibASTMatchersReference.html @@ -194,6 +194,16 @@ Example matches the operator. +Matcher<Decl>cxxDeductionGuideDeclMatcher<CXXDeductionGuideDecl>... +
Matches user-defined and implicitly generated deduction guide.
+
+Example matches the deduction guide.
+  template<typename T>
+  class X { X(int) };
+  X(int) -> X<int>;
+
+ + Matcher<Decl>cxxDestructorDeclMatcher<CXXDestructorDecl>...
Matches explicit C++ destructor declarations.
 
@@ -2222,18 +2232,26 @@ cxxConstructorDecl(isDelegatingConstructor()) will match #3 and #4, but not
 
 
 Matcher<CXXConstructorDecl>isExplicit
-
Matches constructor and conversion declarations that are marked with
-the explicit keyword.
+
Matches constructor, conversion function, and deduction guide declarations
+that have an explicit specifier if this explicit specifier is resolved to
+true.
 
 Given
+  template<bool b>
   struct S {
     S(int); // #1
     explicit S(double); // #2
     operator int(); // #3
     explicit operator bool(); // #4
+    explicit(false) S(bool) // # 7
+    explicit(true) S(char) // # 8
+    explicit(b) S(S) // # 9
   };
-cxxConstructorDecl(isExplicit()) will match #2, but not #1.
+  S(int) -> S<true> // #5
+  explicit S(double) -> S<false> // #6
+cxxConstructorDecl(isExplicit()) will match #2 and #8, but not #1, #7 or #9.
 cxxConversionDecl(isExplicit()) will match #4, but not #3.
+cxxDeductionGuideDecl(isExplicit()) will match #6, but not #5.
 
@@ -2251,18 +2269,26 @@ cxxConstructorDecl(isMoveConstructor()) will match #3, but not #1 or #2. Matcher<CXXConversionDecl>isExplicit -
Matches constructor and conversion declarations that are marked with
-the explicit keyword.
+
Matches constructor, conversion function, and deduction guide declarations
+that have an explicit specifier if this explicit specifier is resolved to
+true.
 
 Given
+  template<bool b>
   struct S {
     S(int); // #1
     explicit S(double); // #2
     operator int(); // #3
     explicit operator bool(); // #4
+    explicit(false) S(bool) // # 7
+    explicit(true) S(char) // # 8
+    explicit(b) S(S) // # 9
   };
-cxxConstructorDecl(isExplicit()) will match #2, but not #1.
+  S(int) -> S<true> // #5
+  explicit S(double) -> S<false> // #6
+cxxConstructorDecl(isExplicit()) will match #2 and #8, but not #1, #7 or #9.
 cxxConversionDecl(isExplicit()) will match #4, but not #3.
+cxxDeductionGuideDecl(isExplicit()) will match #6, but not #5.
 
@@ -2317,6 +2343,30 @@ cxxConstructorDecl(hasAnyConstructorInitializer(isWritten()))
+Matcher<CXXDeductionGuideDecl>isExplicit +
Matches constructor, conversion function, and deduction guide declarations
+that have an explicit specifier if this explicit specifier is resolved to
+true.
+
+Given
+  template<bool b>
+  struct S {
+    S(int); // #1
+    explicit S(double); // #2
+    operator int(); // #3
+    explicit operator bool(); // #4
+    explicit(false) S(bool) // # 7
+    explicit(true) S(char) // # 8
+    explicit(b) S(S) // # 9
+  };
+  S(int) -> S<true> // #5
+  explicit S(double) -> S<false> // #6
+cxxConstructorDecl(isExplicit()) will match #2 and #8, but not #1, #7 or #9.
+cxxConversionDecl(isExplicit()) will match #4, but not #3.
+cxxDeductionGuideDecl(isExplicit()) will match #6, but not #5.
+
+ + Matcher<CXXDependentScopeMemberExpr>isArrow
Matches member expressions that are called with '->' as opposed
 to '.'.
@@ -6007,6 +6057,29 @@ with compoundStmt()
 
+Matcher<FunctionDecl>hasExplicitSpecifierMatcher<Expr> InnerMatcher +
Matches the expression in an explicit specifier if present in the given
+declaration.
+
+Given
+  template<bool b>
+  struct S {
+    S(int); // #1
+    explicit S(double); // #2
+    operator int(); // #3
+    explicit operator bool(); // #4
+    explicit(false) S(bool) // # 7
+    explicit(true) S(char) // # 8
+    explicit(b) S(S) // # 9
+  };
+  S(int) -> S<true> // #5
+  explicit S(double) -> S<false> // #6
+cxxConstructorDecl(hasExplicitSpecifier(constantExpr())) will match #7, #8 and #9, but not #1 or #2.
+cxxConversionDecl(hasExplicitSpecifier(constantExpr())) will not match #3 or #4.
+cxxDeductionGuideDecl(hasExplicitSpecifier(constantExpr())) will not match #5 or #6.
+
+ + Matcher<FunctionDecl>hasParameterunsigned N, Matcher<ParmVarDecl> InnerMatcher
Matches the n'th parameter of a function or an ObjC method
 declaration or a block.
-- 
cgit v1.2.3