From: Aaron Ballman Date: Tue, 10 Jan 2023 14:51:57 +0000 (-0500) Subject: Update dump_ast_matchers.py to Python 3 X-Git-Tag: upstream/17.0.6~21546 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=95be33fb99a605f7261b5eb78ab25954e2e5ce26;p=platform%2Fupstream%2Fllvm.git Update dump_ast_matchers.py to Python 3 Also regenerates the documentation and fixed a validation diagnostic about use of 'is' vs '=='. --- diff --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html index f9cb9f2..e49eb84 100644 --- a/clang/docs/LibASTMatchersReference.html +++ b/clang/docs/LibASTMatchersReference.html @@ -3940,6 +3940,28 @@ implicit default/copy constructors). +Matcher<Decl>isInAnonymousNamespace +
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.
+
+ + Matcher<Decl>isInStdNamespace
Matches declarations in the namespace `std`, but not in nested namespaces.
 
@@ -3962,25 +3984,6 @@ Given
 cxxRecordDecl(hasName("vector"), isInStdNamespace()) will match only #1.
 
-Matcher<Decl>isInAnonymousNamespace -
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.
-
Matcher<Decl>isInstantiated
Matches declarations that are template instantiations or are inside
@@ -8550,7 +8553,7 @@ Usable as: Matcher<LambdaCapture>capturesVarMatcher<VarDecl> InnerMatcher
+Matcher<LambdaCapture>capturesVarMatcher<ValueDecl> InnerMatcher
 
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 2ac0af1..d3f39ee 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 @@ except ImportError:
 
 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 @@ Flags can be combined with '|' example \"IgnoreCase | BasicRegex\"
       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 @@ reference = re.sub(r'',
 reference = re.sub(r'',
                    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)