summaryrefslogtreecommitdiffstats
path: root/clang/docs/tools
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2013-01-09 09:38:21 +0000
committerManuel Klimek <klimek@google.com>2013-01-09 09:38:21 +0000
commitcdd5c2397a9c0010e95b9b9f5611b3dde35ecf98 (patch)
tree3e4936104ef15acf763823fd50e267661fee4149 /clang/docs/tools
parentd8bb2db2429e1cb0c4ff87ad4f706f36991c85a9 (diff)
downloadbcm5719-llvm-cdd5c2397a9c0010e95b9b9f5611b3dde35ecf98.tar.gz
bcm5719-llvm-cdd5c2397a9c0010e95b9b9f5611b3dde35ecf98.zip
Fixes dump_ast_matchers to parse all matcher macros and updates the
docs. llvm-svn: 171962
Diffstat (limited to 'clang/docs/tools')
-rw-r--r--clang/docs/tools/dump_ast_matchers.py41
1 files changed, 36 insertions, 5 deletions
diff --git a/clang/docs/tools/dump_ast_matchers.py b/clang/docs/tools/dump_ast_matchers.py
index bc5f1a64a5c..cd7ab0b74f1 100644
--- a/clang/docs/tools/dump_ast_matchers.py
+++ b/clang/docs/tools/dump_ast_matchers.py
@@ -133,17 +133,48 @@ def act_on_decl(declaration, comment, allowed_types):
if declaration.strip():
# Node matchers are defined by writing:
# VariadicDynCastAllOfMatcher<ResultType, ArgumentType> name;
- m = re.match(r""".*VariadicDynCastAllOfMatcher\s*<
- \s*([^\s,]+)\s*,
- \s*([^\s>]+)\s*>
+ m = re.match(r""".*Variadic(?:DynCast)?AllOfMatcher\s*<
+ \s*([^\s,]+)\s*(?:,
+ \s*([^\s>]+)\s*)?>
\s*([^\s;]+)\s*;\s*$""", declaration, flags=re.X)
if m:
result, inner, name = m.groups()
+ if not inner:
+ inner = result
add_matcher(result, name, 'Matcher<%s>...' % inner,
comment, is_dyncast=True)
return
# Parse the various matcher definition macros.
+ m = re.match(""".*AST_TYPE_MATCHER\(
+ \s*([^\s,]+\s*),
+ \s*([^\s,]+\s*)
+ \)\s*;\s*$""", declaration, flags=re.X)
+ if m:
+ inner, name = m.groups()
+ add_matcher('Type', name, 'Matcher<%s>...' % inner,
+ comment, is_dyncast=True)
+ add_matcher('TypeLoc', '%sLoc' % name, 'Matcher<%sLoc>...' % inner,
+ comment, is_dyncast=True)
+ return
+
+ m = re.match(""".*AST_TYPE(LOC)?_TRAVERSE_MATCHER\(
+ \s*([^\s,]+\s*),
+ \s*(?:[^\s,]+\s*)
+ \)\s*;\s*$""", declaration, flags=re.X)
+ if m:
+ loc = m.group(1)
+ name = m.group(2)
+ result_types = extract_result_types(comment)
+ if not result_types:
+ raise Exception('Did not find allowed result types for: %s' % name)
+ for result_type in result_types:
+ add_matcher(result_type, name, 'Matcher<Type>', comment)
+ if loc:
+ add_matcher('%sLoc' % result_type, '%sLoc' % name, 'Matcher<TypeLoc>',
+ comment)
+ return
+
m = re.match(r"""^\s*AST_(POLYMORPHIC_)?MATCHER(_P)?(.?)\(
(?:\s*([^\s,]+)\s*,)?
\s*([^\s,]+)\s*
@@ -178,9 +209,9 @@ def act_on_decl(declaration, comment, allowed_types):
if m:
result, name, args = m.groups()
args = ', '.join(p.strip() for p in args.split(','))
- m = re.match(r'.*\s+internal::Matcher<([^>]+)>$', result)
+ m = re.match(r'.*\s+internal::(Bindable)?Matcher<([^>]+)>$', result)
if m:
- result_types = [m.group(1)]
+ result_types = [m.group(2)]
else:
result_types = extract_result_types(comment)
if not result_types:
OpenPOWER on IntegriCloud