From 03a83238c39e290ed6e2ced7663efa9fa8c19158 Mon Sep 17 00:00:00 2001 From: Manuel Klimek Date: Mon, 10 Jun 2013 08:52:15 +0000 Subject: [PATCH] Fixes the comment for hasDeclaration. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183640 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/LibASTMatchersReference.html | 148 +++++++++++++++++++----- include/clang/ASTMatchers/ASTMatchers.h | 19 ++- 2 files changed, 130 insertions(+), 37 deletions(-) diff --git a/docs/LibASTMatchersReference.html b/docs/LibASTMatchersReference.html index 0ea55bfef5..c80a749df2 100644 --- a/docs/LibASTMatchersReference.html +++ b/docs/LibASTMatchersReference.html @@ -352,6 +352,16 @@ Example matches x.y() and y() +Matcher<Stmt>caseStmtMatcher<CaseStmt>... +
Matches case statements inside switch statements.
+
+Given
+  switch(a) { case 42: break; default: break; }
+caseStmt()
+  matches 'case 42: break;'.
+
+ + Matcher<Stmt>castExprMatcher<CastExpr>...
Matches any cast nodes of Clang's AST.
 
@@ -471,6 +481,16 @@ Example matches the CXXDefaultArgExpr placeholder inserted for the
 
+Matcher<Stmt>defaultStmtMatcher<DefaultStmt>... +
Matches default statements inside switch statements.
+
+Given
+  switch(a) { case 42: break; default: break; }
+defaultStmt()
+  matches 'default: break;'.
+
+ + Matcher<Stmt>deleteExprMatcher<CXXDeleteExpr>...
Matches delete expressions.
 
@@ -2328,12 +2348,19 @@ Usable as: Matcher<CXXConstructExpr>hasDeclarationMatcher<Decl>  InnerMatcher
-
Matches a type if the declaration of the type matches the given
-matcher.
+
Matches a node if the declaration associated with that node
+matches the given matcher.
 
-In addition to being usable as Matcher<TypedefType>, also usable as
-Matcher<T> for any T supporting the getDecl() member function. e.g. various
-subtypes of clang::Type.
+The associated declaration is:
+- for type nodes, the declaration of the underlying type
+- for CallExpr, the declaration of the callee
+- for MemberExpr, the declaration of the referenced member
+- for CXXConstructExpr, the declaration of the constructor
+
+Also usable as Matcher<T> for any T supporting the getDecl() member
+function. e.g. various subtypes of clang::Type and various expressions.
+FIXME: Add all node types for which this is matcher is usable due to
+getDecl().
 
 Usable as: Matcher<QualType>, Matcher<CallExpr>, Matcher<CXXConstructExpr>,
   Matcher<MemberExpr>, Matcher<TypedefType>,
@@ -2496,12 +2523,19 @@ Example matches y in x(y)
 
 
 Matcher<CallExpr>hasDeclarationMatcher<Decl>  InnerMatcher
-
Matches a type if the declaration of the type matches the given
-matcher.
+
Matches a node if the declaration associated with that node
+matches the given matcher.
 
-In addition to being usable as Matcher<TypedefType>, also usable as
-Matcher<T> for any T supporting the getDecl() member function. e.g. various
-subtypes of clang::Type.
+The associated declaration is:
+- for type nodes, the declaration of the underlying type
+- for CallExpr, the declaration of the callee
+- for MemberExpr, the declaration of the referenced member
+- for CXXConstructExpr, the declaration of the constructor
+
+Also usable as Matcher<T> for any T supporting the getDecl() member
+function. e.g. various subtypes of clang::Type and various expressions.
+FIXME: Add all node types for which this is matcher is usable due to
+getDecl().
 
 Usable as: Matcher<QualType>, Matcher<CallExpr>, Matcher<CXXConstructExpr>,
   Matcher<MemberExpr>, Matcher<TypedefType>,
@@ -2509,6 +2543,17 @@ Usable as: Matcher<CaseStmt>hasCaseConstantMatcher<Expr> InnerMatcher
+
If the given case statement does not use the GNU case range
+extension, matches the constant given in the statement.
+
+Given
+  switch (1) { case 1: case 1+1: case 3 ... 4: ; }
+caseStmt(hasCaseConstant(integerLiteral()))
+  matches "case 1:"
+
+ + Matcher<CastExpr>hasSourceExpressionMatcher<Expr> InnerMatcher
Matches if the cast's source expression matches the given matcher.
 
@@ -2944,12 +2989,19 @@ FIXME: Unit test this matcher
 
 
 Matcher<MemberExpr>hasDeclarationMatcher<Decl>  InnerMatcher
-
Matches a type if the declaration of the type matches the given
-matcher.
+
Matches a node if the declaration associated with that node
+matches the given matcher.
 
-In addition to being usable as Matcher<TypedefType>, also usable as
-Matcher<T> for any T supporting the getDecl() member function. e.g. various
-subtypes of clang::Type.
+The associated declaration is:
+- for type nodes, the declaration of the underlying type
+- for CallExpr, the declaration of the callee
+- for MemberExpr, the declaration of the referenced member
+- for CXXConstructExpr, the declaration of the constructor
+
+Also usable as Matcher<T> for any T supporting the getDecl() member
+function. e.g. various subtypes of clang::Type and various expressions.
+FIXME: Add all node types for which this is matcher is usable due to
+getDecl().
 
 Usable as: Matcher<QualType>, Matcher<CallExpr>, Matcher<CXXConstructExpr>,
   Matcher<MemberExpr>, Matcher<TypedefType>,
@@ -3142,12 +3194,19 @@ declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType()))
 
 
 Matcher<QualType>hasDeclarationMatcher<Decl>  InnerMatcher
-
Matches a type if the declaration of the type matches the given
-matcher.
+
Matches a node if the declaration associated with that node
+matches the given matcher.
 
-In addition to being usable as Matcher<TypedefType>, also usable as
-Matcher<T> for any T supporting the getDecl() member function. e.g. various
-subtypes of clang::Type.
+The associated declaration is:
+- for type nodes, the declaration of the underlying type
+- for CallExpr, the declaration of the callee
+- for MemberExpr, the declaration of the referenced member
+- for CXXConstructExpr, the declaration of the constructor
+
+Also usable as Matcher<T> for any T supporting the getDecl() member
+function. e.g. various subtypes of clang::Type and various expressions.
+FIXME: Add all node types for which this is matcher is usable due to
+getDecl().
 
 Usable as: Matcher<QualType>, Matcher<CallExpr>, Matcher<CXXConstructExpr>,
   Matcher<MemberExpr>, Matcher<TypedefType>,
@@ -3209,6 +3268,19 @@ sizeof.
 
+Matcher<SwitchStmt>forEachSwitchCaseMatcher<SwitchCase> InnerMatcher +
Matches each case or default statement belonging to the given switch
+statement. This matcher may produce multiple matches.
+
+Given
+  switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } }
+switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s")
+  matches four times, with "c" binding each of "case 1:", "case 2:",
+"case 3:" and "case 4:", and "s" respectively binding "switch (1)",
+"switch (1)", "switch (2)" and "switch (2)".
+
+ + Matcher<TemplateArgument>refersToDeclarationMatcher<Decl> InnerMatcher
Matches a TemplateArgument that refers to a certain declaration.
 
@@ -3237,12 +3309,19 @@ classTemplateSpecializationDecl(hasAnyTemplateArgument(
 
 
 Matcher<TemplateSpecializationType>hasDeclarationMatcher<Decl>  InnerMatcher
-
Matches a type if the declaration of the type matches the given
-matcher.
+
Matches a node if the declaration associated with that node
+matches the given matcher.
+
+The associated declaration is:
+- for type nodes, the declaration of the underlying type
+- for CallExpr, the declaration of the callee
+- for MemberExpr, the declaration of the referenced member
+- for CXXConstructExpr, the declaration of the constructor
 
-In addition to being usable as Matcher<TypedefType>, also usable as
-Matcher<T> for any T supporting the getDecl() member function. e.g. various
-subtypes of clang::Type.
+Also usable as Matcher<T> for any T supporting the getDecl() member
+function. e.g. various subtypes of clang::Type and various expressions.
+FIXME: Add all node types for which this is matcher is usable due to
+getDecl().
 
 Usable as: Matcher<QualType>, Matcher<CallExpr>, Matcher<CXXConstructExpr>,
   Matcher<MemberExpr>, Matcher<TypedefType>,
@@ -3257,12 +3336,19 @@ QualType-matcher matches.
 
 
 Matcher<TypedefType>hasDeclarationMatcher<Decl>  InnerMatcher
-
Matches a type if the declaration of the type matches the given
-matcher.
-
-In addition to being usable as Matcher<TypedefType>, also usable as
-Matcher<T> for any T supporting the getDecl() member function. e.g. various
-subtypes of clang::Type.
+
Matches a node if the declaration associated with that node
+matches the given matcher.
+
+The associated declaration is:
+- for type nodes, the declaration of the underlying type
+- for CallExpr, the declaration of the callee
+- for MemberExpr, the declaration of the referenced member
+- for CXXConstructExpr, the declaration of the constructor
+
+Also usable as Matcher<T> for any T supporting the getDecl() member
+function. e.g. various subtypes of clang::Type and various expressions.
+FIXME: Add all node types for which this is matcher is usable due to
+getDecl().
 
 Usable as: Matcher<QualType>, Matcher<CallExpr>, Matcher<CXXConstructExpr>,
   Matcher<MemberExpr>, Matcher<TypedefType>,
diff --git a/include/clang/ASTMatchers/ASTMatchers.h b/include/clang/ASTMatchers/ASTMatchers.h
index 61f11060d8..a66f3afe00 100644
--- a/include/clang/ASTMatchers/ASTMatchers.h
+++ b/include/clang/ASTMatchers/ASTMatchers.h
@@ -1682,12 +1682,19 @@ unless(const M &InnerMatcher) {
     internal::NotMatcher, M>(InnerMatcher);
 }
 
-/// \brief Matches a type if the declaration of the type matches the given
-/// matcher.
-///
-/// In addition to being usable as Matcher, also usable as
-/// Matcher for any T supporting the getDecl() member function. e.g. various
-/// subtypes of clang::Type.
+/// \brief Matches a node if the declaration associated with that node
+/// matches the given matcher.
+///
+/// The associated declaration is:
+/// - for type nodes, the declaration of the underlying type
+/// - for CallExpr, the declaration of the callee
+/// - for MemberExpr, the declaration of the referenced member
+/// - for CXXConstructExpr, the declaration of the constructor
+///
+/// Also usable as Matcher for any T supporting the getDecl() member
+/// function. e.g. various subtypes of clang::Type and various expressions.
+/// FIXME: Add all node types for which this is matcher is usable due to
+/// getDecl().
 ///
 /// Usable as: Matcher, Matcher, Matcher,
 ///   Matcher, Matcher,
-- 
2.40.0