diff options
author | Manuel Klimek <klimek@google.com> | 2013-01-09 09:38:21 +0000 |
---|---|---|
committer | Manuel Klimek <klimek@google.com> | 2013-01-09 09:38:21 +0000 |
commit | 41df16e2a835f547b9384643e1804e75940e74dd (patch) | |
tree | 9da319ee15e4ac9b537c6f7f3277433ee7de6333 /docs/tools/dump_ast_matchers.py | |
parent | 043835aa876b1edeca0a05def0cc0989faa15892 (diff) |
Fixes dump_ast_matchers to parse all matcher macros and updates the
docs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171962 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/tools/dump_ast_matchers.py')
-rw-r--r-- | docs/tools/dump_ast_matchers.py | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/docs/tools/dump_ast_matchers.py b/docs/tools/dump_ast_matchers.py index bc5f1a64a5..cd7ab0b74f 100644 --- a/docs/tools/dump_ast_matchers.py +++ b/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: |