Author: Aaron Ballman Date: 2023-01-10T09:53:06-05:00 New Revision: 95be33fb99a605f7261b5eb78ab25954e2e5ce26
URL: https://github.com/llvm/llvm-project/commit/95be33fb99a605f7261b5eb78ab25954e2e5ce26 DIFF: https://github.com/llvm/llvm-project/commit/95be33fb99a605f7261b5eb78ab25954e2e5ce26.diff LOG: Update dump_ast_matchers.py to Python 3 Also regenerates the documentation and fixed a validation diagnostic about use of 'is' vs '=='. Added: Modified: clang/docs/LibASTMatchersReference.html clang/docs/tools/dump_ast_matchers.py Removed: ################################################################################ diff --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html index f9cb9f2e942b..e49eb8430f47 100644 --- a/clang/docs/LibASTMatchersReference.html +++ b/clang/docs/LibASTMatchersReference.html @@ -3940,6 +3940,28 @@ <h2 id="narrowing-matchers">Narrowing Matchers</h2> </pre></td></tr> +<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isInAnonymousNamespace0')"><a name="isInAnonymousNamespace0Anchor">isInAnonymousNamespace</a></td><td></td></tr> +<tr><td colspan="4" class="doc" id="isInAnonymousNamespace0"><pre>Matches declarations in an anonymous namespace. + +Given + class vector {}; + namespace foo { + class vector {}; + namespace { + class vector {}; // #1 + } + } + namespace { + class vector {}; // #2 + namespace foo { + class vector{}; // #3 + } + } +cxxRecordDecl(hasName("vector"), isInAnonymousNamespace()) will match +#1, #2 and #3. +</pre></td></tr> + + <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isInStdNamespace0')"><a name="isInStdNamespace0Anchor">isInStdNamespace</a></td><td></td></tr> <tr><td colspan="4" class="doc" id="isInStdNamespace0"><pre>Matches declarations in the namespace `std`, but not in nested namespaces. @@ -3962,25 +3984,6 @@ <h2 id="narrowing-matchers">Narrowing Matchers</h2> cxxRecordDecl(hasName("vector"), isInStdNamespace()) will match only #1. </pre></td></tr> -<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isInAnonymousNamespace0')"><a name="isInAnonymousNamespace0Anchor">isInAnonymousNamespace</a></td><td></td></tr> -<tr><td colspan="4" class="doc" id="isInAnonymousNamespace0"><pre>Matches declarations in an anonymous namespace. - -Given - class vector {}; - namespace foo { - class vector {}; - namespace { - class vector {}; // #1 - } - } - namespace { - class vector {}; // #2 - namespace foo { - class vector{}; // #3 - } - } -cxxRecordDecl(hasName("vector"), isInAnonymousNamespace()) will match #1, #2 and #3. -</pre></td></tr> <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isInstantiated0')"><a name="isInstantiated0Anchor">isInstantiated</a></td><td></td></tr> <tr><td colspan="4" class="doc" id="isInstantiated0"><pre>Matches declarations that are template instantiations or are inside @@ -8550,7 +8553,7 @@ <h2 id="traversal-matchers">AST Traversal Matchers</h2> </pre></td></tr> -<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture</a>></td><td class="name" onclick="toggle('capturesVar0')"><a name="capturesVar0Anchor">capturesVar</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>> InnerMatcher</td></tr> +<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture</a>></td><td class="name" onclick="toggle('capturesVar0')"><a name="capturesVar0Anchor">capturesVar</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>> InnerMatcher</td></tr> <tr><td colspan="4" class="doc" id="capturesVar0"><pre>Matches a `LambdaCapture` that refers to the specified `VarDecl`. The `VarDecl` can be a separate variable that is captured by value or reference, or a synthesized variable if the capture has an initializer. diff --git a/clang/docs/tools/dump_ast_matchers.py b/clang/docs/tools/dump_ast_matchers.py index 2ac0af1f38bc..d3f39ee45675 100755 --- a/clang/docs/tools/dump_ast_matchers.py +++ b/clang/docs/tools/dump_ast_matchers.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # A tool to parse ASTMatchers.h and update the documentation in # ../LibASTMatchersReference.html automatically. Run from the # directory in which this file is located to update the docs. @@ -12,7 +12,7 @@ CLASS_INDEX_PAGE_URL = 'https://clang.llvm.org/doxygen/classes.html' try: - CLASS_INDEX_PAGE = urlopen(CLASS_INDEX_PAGE_URL).read() + CLASS_INDEX_PAGE = urlopen(CLASS_INDEX_PAGE_URL).read().decode('utf-8') except Exception as e: raise Exception('Unable to get %s: %s' % (CLASS_INDEX_PAGE_URL, e)) @@ -422,7 +422,7 @@ def act_on_decl(declaration, comment, allowed_types): m = re.match(r'(?:^|.*\s+)internal::(?:Bindable)?Matcher<([^>]+)>$', result) if m: result_types = [m.group(1)] - if template_name and len(result_types) is 1 and result_types[0] == template_name: + if template_name and len(result_types) == 1 and result_types[0] == template_name: result_types = ['*'] else: result_types = extract_result_types(comment) @@ -502,6 +502,6 @@ def sort_table(matcher_type, matcher_map): reference = re.sub(r'<!-- START_TRAVERSAL_MATCHERS.*END_TRAVERSAL_MATCHERS -->', traversal_matcher_table, reference, flags=re.S) -with open('../LibASTMatchersReference.html', 'wb') as output: +with open('../LibASTMatchersReference.html', 'w', newline='\n') as output: output.write(reference) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits