From d3aa1f4a630249026fab3513e3ad3b418a5d50ac Mon Sep 17 00:00:00 2001 From: Manuel Klimek Date: Tue, 25 Nov 2014 17:01:06 +0000 Subject: Re-apply r222646 (was reverted in r222667). Adding 4 ASTMatchers: typedefDecl, isInMainFile, isInSystemFile, isInFileMatchingName Change to original: ifndef out tests in Windows due to /-separated paths. Summary: Often one is only interested in matches within the main-file or matches that are not within a system-header, for which this patch adds isInMainFile and isInSystemFile. They take no arguments and narrow down the matches. The isInFileMatchingName is mainly thought for interactive clang-query-sessions, to make a matcher more specific without restarting the session with the files you are interested in for that moment. It takes a string that will be used as regular-expression to match the filename of where the matched node is expanded. Patch by Hendrik von Prince. llvm-svn: 222765 --- clang/docs/LibASTMatchersReference.html | 147 +++++++++++++++++++++++++++++++- 1 file changed, 146 insertions(+), 1 deletion(-) (limited to 'clang/docs/LibASTMatchersReference.html') diff --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html index 2eabff49cff..e70d1ec3fac 100644 --- a/clang/docs/LibASTMatchersReference.html +++ b/clang/docs/LibASTMatchersReference.html @@ -307,6 +307,16 @@ Example matches X, Z +Matcher<Decl>typedefDeclMatcher<TypedefDecl>... +
Matches typedef declarations.
+
+Given
+  typedef int X;
+typedefDecl()
+  matches "typedef int X"
+
+ + Matcher<Decl>unresolvedUsingValueDeclMatcher<UnresolvedUsingValueDecl>...
Matches unresolved using value declarations.
 
@@ -339,6 +349,15 @@ usingDirectiveDecl()
   matches using namespace X 
+Matcher<Decl>valueDeclMatcher<ValueDecl>... +
Matches any value declaration.
+
+Example matches A, B, C and F
+  enum X { A, B, C };
+  void F();
+
+ + Matcher<Decl>varDeclMatcher<VarDecl>...
Matches variable declarations.
 
@@ -1654,6 +1673,48 @@ f.
 
+Matcher<Decl>isExpansionInFileMatchingstd::string RegExp +
Matches AST nodes that were expanded within files whose name is
+partially matching a given regex.
+
+Example matches Y but not X
+    (matcher = recordDecl(isExpansionInFileMatching("AST.*"))
+  #include "ASTMatcher.h"
+  class X {};
+ASTMatcher.h:
+  class Y {};
+
+Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
+
+ + +Matcher<Decl>isExpansionInMainFile +
Matches AST nodes that were expanded within the main-file.
+
+Example matches X but not Y (matcher = recordDecl(isExpansionInMainFile())
+  #include <Y.h>
+  class X {};
+Y.h:
+  class Y {};
+
+Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
+
+ + +Matcher<Decl>isExpansionInSystemHeader +
Matches AST nodes that were expanded within system-header-files.
+
+Example matches Y but not X
+    (matcher = recordDecl(isExpansionInSystemHeader())
+  #include <SystemHeader.h>
+  class X {};
+SystemHeader.h:
+  class Y {};
+
+Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
+
+ + Matcher<Decl>isImplicit
Matches a declaration that has been implicitly added
 by the compiler (eg. implicit defaultcopy constructors).
@@ -1858,7 +1919,7 @@ memberExpr(isArrow())
 
-Matcher<NamedDecl>hasNamestd::string Name +Matcher<NamedDecl>hasNamestd::string Name
Matches NamedDecl nodes that have the specified name.
 
 Supports specifying enclosing namespaces or classes by prefixing the name
@@ -1990,6 +2051,48 @@ and reference to that variable declaration within a compound statement.
 
+Matcher<Stmt>isExpansionInFileMatchingstd::string RegExp +
Matches AST nodes that were expanded within files whose name is
+partially matching a given regex.
+
+Example matches Y but not X
+    (matcher = recordDecl(isExpansionInFileMatching("AST.*"))
+  #include "ASTMatcher.h"
+  class X {};
+ASTMatcher.h:
+  class Y {};
+
+Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
+
+ + +Matcher<Stmt>isExpansionInMainFile +
Matches AST nodes that were expanded within the main-file.
+
+Example matches X but not Y (matcher = recordDecl(isExpansionInMainFile())
+  #include <Y.h>
+  class X {};
+Y.h:
+  class Y {};
+
+Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
+
+ + +Matcher<Stmt>isExpansionInSystemHeader +
Matches AST nodes that were expanded within system-header-files.
+
+Example matches Y but not X
+    (matcher = recordDecl(isExpansionInSystemHeader())
+  #include <SystemHeader.h>
+  class X {};
+SystemHeader.h:
+  class Y {};
+
+Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
+
+ + Matcher<Stmt>isInTemplateInstantiation
Matches statements inside of a template instantiation.
 
@@ -2061,6 +2164,48 @@ classTemplateSpecializationDecl(templateArgumentCountIs(1))
 
+Matcher<TypeLoc>isExpansionInFileMatchingstd::string RegExp +
Matches AST nodes that were expanded within files whose name is
+partially matching a given regex.
+
+Example matches Y but not X
+    (matcher = recordDecl(isExpansionInFileMatching("AST.*"))
+  #include "ASTMatcher.h"
+  class X {};
+ASTMatcher.h:
+  class Y {};
+
+Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
+
+ + +Matcher<TypeLoc>isExpansionInMainFile +
Matches AST nodes that were expanded within the main-file.
+
+Example matches X but not Y (matcher = recordDecl(isExpansionInMainFile())
+  #include <Y.h>
+  class X {};
+Y.h:
+  class Y {};
+
+Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
+
+ + +Matcher<TypeLoc>isExpansionInSystemHeader +
Matches AST nodes that were expanded within system-header-files.
+
+Example matches Y but not X
+    (matcher = recordDecl(isExpansionInSystemHeader())
+  #include <SystemHeader.h>
+  class X {};
+SystemHeader.h:
+  class Y {};
+
+Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
+
+ + Matcher<Type>equalsBoundNodestd::string ID
Matches if a node equals a previously bound node.
 
-- 
cgit v1.2.3