[PATCH] D75046: [docs] dump_ast_matchers strips internal::(Bindable)?Matcher from Result_type

2020-02-24 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe6f9cb025cd7: [docs] dump_ast_matchers strips 
internal::(Bindable)?Matcher from Result_type (authored by njames93).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75046/new/

https://reviews.llvm.org/D75046

Files:
  clang/docs/LibASTMatchersReference.html
  clang/docs/tools/dump_ast_matchers.py
  clang/include/clang/ASTMatchers/ASTMatchers.h

Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -307,7 +307,7 @@
 ///
 /// FIXME: Change to be a polymorphic matcher that works on any syntactic
 /// node. There's nothing `Stmt`-specific about it.
-AST_MATCHER_P(clang::Stmt, isExpandedFromMacro, llvm::StringRef, MacroName) {
+AST_MATCHER_P(Stmt, isExpandedFromMacro, llvm::StringRef, MacroName) {
   // Verifies that the statement' beginning and ending are both expanded from
   // the same instance of the given macro.
   auto& Context = Finder->getASTContext();
Index: clang/docs/tools/dump_ast_matchers.py
===
--- clang/docs/tools/dump_ast_matchers.py
+++ clang/docs/tools/dump_ast_matchers.py
@@ -103,6 +103,11 @@
   args = re.sub(r'(^|\s)M\d?(\s)', r'\1Matcher<*>\2', args)
   return args
 
+def unify_type(result_type):
+  """Gets rid of anything the user doesn't care about in the type name."""
+  result_type = re.sub(r'^internal::(Bindable)?Matcher<([a-zA-Z_][a-zA-Z0-9_]*)>$', r'\2', result_type)
+  return result_type
+
 def add_matcher(result_type, name, args, comment, is_dyncast=False):
   """Adds a matcher to one of our categories."""
   if name == 'id':
@@ -111,6 +116,7 @@
   matcher_id = '%s%d' % (name, ids[name])
   ids[name] += 1
   args = unify_arguments(args)
+  result_type = unify_type(result_type)
   matcher_html = TD_TEMPLATE % {
 'result': esc('Matcher<%s>' % result_type),
 'name': name,
Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -2948,6 +2948,19 @@
 
 
 
+MatcherDecl>isInstantiated
+Matches declarations that are template instantiations or are inside
+template instantiations.
+
+Given
+  template void A(T t) { T i; }
+  A(0);
+  A(0U);
+functionDecl(isInstantiated())
+  matches 'A(int) {...};' and 'A(unsigned) {...}'.
+
+
+
 MatcherDecl>isPrivate
 Matches private C++ declarations.
 
@@ -3516,6 +3529,16 @@
 
 
 
+MatcherNamedDecl>hasAnyNameStringRef, ..., StringRef
+Matches NamedDecl nodes that have any of the specified names.
+
+This matcher is only provided as a performance optimization of hasName.
+hasAnyName(a, b, c)
+ is equivalent to, but faster than
+anyOf(hasName(a), hasName(b), hasName(c))
+
+
+
 MatcherNamedDecl>hasExternalFormalLinkage
 Matches a declaration that has external formal linkage.
 
@@ -3679,6 +3702,17 @@
 
 
 
+MatcherObjCMessageExpr>hasAnySelectorStringRef, ..., StringRef
+Matches when at least one of the supplied string equals to the
+Selector.getAsString()
+
+ matcher = objCMessageExpr(hasSelector("methodA:", "methodB:"));
+ matches both of the expressions below:
+[myObj methodA:argA];
+[myObj methodB:argB];
+
+
+
 MatcherObjCMessageExpr>hasKeywordSelector
 Matches when the selector is a keyword selector
 
@@ -4015,6 +4049,17 @@
 
 
 
+MatcherStmt>isExpandedFromMacrollvm::StringRef MacroName
+Matches statements that are (transitively) expanded from the named macro.
+Does not match if only part of the statement is expanded from that macro or
+if different parts of the the statement are expanded from different
+appearances of the macro.
+
+FIXME: Change to be a polymorphic matcher that works on any syntactic
+node. There's nothing `Stmt`-specific about it.
+
+
+
 MatcherStmt>isExpansionInFileMatchingstd::string RegExp
 Matches AST nodes that were expanded within files whose name is
 partially matching a given regex.
@@ -4058,6 +4103,22 @@
 
 
 
+MatcherStmt>isInTemplateInstantiation
+Matches statements inside of a template instantiation.
+
+Given
+  int j;
+  template void A(T t) { T i; j += 42;}
+  A(0);
+  A(0U);
+declStmt(isInTemplateInstantiation())
+  mat

[PATCH] D75046: [docs] dump_ast_matchers strips internal::(Bindable)?Matcher from Result_type

2020-02-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75046/new/

https://reviews.llvm.org/D75046



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75046: [docs] dump_ast_matchers strips internal::(Bindable)?Matcher from Result_type

2020-02-24 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: joerg, gribozavr2, aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Remove `internal::Matcher` and `internal::BindableMatcher` from Result Type 
when dumping AST Matchers


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75046

Files:
  clang/docs/LibASTMatchersReference.html
  clang/docs/tools/dump_ast_matchers.py
  clang/include/clang/ASTMatchers/ASTMatchers.h

Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -307,7 +307,7 @@
 ///
 /// FIXME: Change to be a polymorphic matcher that works on any syntactic
 /// node. There's nothing `Stmt`-specific about it.
-AST_MATCHER_P(clang::Stmt, isExpandedFromMacro, llvm::StringRef, MacroName) {
+AST_MATCHER_P(Stmt, isExpandedFromMacro, llvm::StringRef, MacroName) {
   // Verifies that the statement' beginning and ending are both expanded from
   // the same instance of the given macro.
   auto& Context = Finder->getASTContext();
Index: clang/docs/tools/dump_ast_matchers.py
===
--- clang/docs/tools/dump_ast_matchers.py
+++ clang/docs/tools/dump_ast_matchers.py
@@ -103,6 +103,11 @@
   args = re.sub(r'(^|\s)M\d?(\s)', r'\1Matcher<*>\2', args)
   return args
 
+def unify_type(result_type):
+  """Gets rid of anything the user doesn't care about in the type name."""
+  result_type = re.sub(r'^internal::(Bindable)?Matcher<([a-zA-Z_][a-zA-Z0-9_]*)>$', r'\2', result_type)
+  return result_type
+
 def add_matcher(result_type, name, args, comment, is_dyncast=False):
   """Adds a matcher to one of our categories."""
   if name == 'id':
@@ -111,6 +116,7 @@
   matcher_id = '%s%d' % (name, ids[name])
   ids[name] += 1
   args = unify_arguments(args)
+  result_type = unify_type(result_type)
   matcher_html = TD_TEMPLATE % {
 'result': esc('Matcher<%s>' % result_type),
 'name': name,
Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -2948,6 +2948,19 @@
 
 
 
+MatcherDecl>isInstantiated
+Matches declarations that are template instantiations or are inside
+template instantiations.
+
+Given
+  template void A(T t) { T i; }
+  A(0);
+  A(0U);
+functionDecl(isInstantiated())
+  matches 'A(int) {...};' and 'A(unsigned) {...}'.
+
+
+
 MatcherDecl>isPrivate
 Matches private C++ declarations.
 
@@ -3516,6 +3529,16 @@
 
 
 
+MatcherNamedDecl>hasAnyNameStringRef, ..., StringRef
+Matches NamedDecl nodes that have any of the specified names.
+
+This matcher is only provided as a performance optimization of hasName.
+hasAnyName(a, b, c)
+ is equivalent to, but faster than
+anyOf(hasName(a), hasName(b), hasName(c))
+
+
+
 MatcherNamedDecl>hasExternalFormalLinkage
 Matches a declaration that has external formal linkage.
 
@@ -3679,6 +3702,17 @@
 
 
 
+MatcherObjCMessageExpr>hasAnySelectorStringRef, ..., StringRef
+Matches when at least one of the supplied string equals to the
+Selector.getAsString()
+
+ matcher = objCMessageExpr(hasSelector("methodA:", "methodB:"));
+ matches both of the expressions below:
+[myObj methodA:argA];
+[myObj methodB:argB];
+
+
+
 MatcherObjCMessageExpr>hasKeywordSelector
 Matches when the selector is a keyword selector
 
@@ -4015,6 +4049,17 @@
 
 
 
+MatcherStmt>isExpandedFromMacrollvm::StringRef MacroName
+Matches statements that are (transitively) expanded from the named macro.
+Does not match if only part of the statement is expanded from that macro or
+if different parts of the the statement are expanded from different
+appearances of the macro.
+
+FIXME: Change to be a polymorphic matcher that works on any syntactic
+node. There's nothing `Stmt`-specific about it.
+
+
+
 MatcherStmt>isExpansionInFileMatchingstd::string RegExp
 Matches AST nodes that were expanded within files whose name is
 partially matching a given regex.
@@ -4058,6 +4103,22 @@
 
 
 
+MatcherStmt>isInTemplateInstantiation
+Matches statements inside of a template instantiation.
+
+Given
+  int j;
+  template void A(T t) { T i; j += 42;}
+  A(0);
+  A(0U);
+declStmt(isInTemplateInstantiation())
+  matches 'in