[clang] fix(clang/**.py): fix invalid escape sequences (PR #94029)
via cfe-commits
cfe-commits at lists.llvm.org
Fri May 31 12:45:59 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Eisuke Kawashima (e-kwsm)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/94029.diff
2 Files Affected:
- (modified) clang/docs/tools/dump_ast_matchers.py (+5-5)
- (modified) clang/test/Analysis/check-analyzer-fixit.py (+1-1)
``````````diff
diff --git a/clang/docs/tools/dump_ast_matchers.py b/clang/docs/tools/dump_ast_matchers.py
index 705ff0d4d4098..d47111819a1e2 100755
--- a/clang/docs/tools/dump_ast_matchers.py
+++ b/clang/docs/tools/dump_ast_matchers.py
@@ -86,11 +86,11 @@ def extract_result_types(comment):
parsed.
"""
result_types = []
- m = re.search(r"Usable as: Any Matcher[\s\n]*$", comment, re.S)
+ m = re.search("Usable as: Any Matcher[\\s\n]*$", comment, re.S)
if m:
return ["*"]
while True:
- m = re.match(r"^(.*)Matcher<([^>]+)>\s*,?[\s\n]*$", comment, re.S)
+ m = re.match("^(.*)Matcher<([^>]+)>\\s*,?[\\s\n]*$", comment, re.S)
if not m:
if re.search(r"Usable as:\s*$", comment):
return result_types
@@ -101,9 +101,9 @@ def extract_result_types(comment):
def strip_doxygen(comment):
- """Returns the given comment without \-escaped words."""
+ r"""Returns the given comment without \-escaped words."""
# If there is only a doxygen keyword in the line, delete the whole line.
- comment = re.sub(r"^\\[^\s]+\n", r"", comment, flags=re.M)
+ comment = re.sub("^\\\\[^\\s]+\n", r"", comment, flags=re.M)
# If there is a doxygen \see command, change the \see prefix into "See also:".
# FIXME: it would be better to turn this into a link to the target instead.
@@ -236,7 +236,7 @@ def act_on_decl(declaration, comment, allowed_types):
# Parse the various matcher definition macros.
m = re.match(
- """.*AST_TYPE(LOC)?_TRAVERSE_MATCHER(?:_DECL)?\(
+ r""".*AST_TYPE(LOC)?_TRAVERSE_MATCHER(?:_DECL)?\(
\s*([^\s,]+\s*),
\s*(?:[^\s,]+\s*),
\s*AST_POLYMORPHIC_SUPPORTED_TYPES\(([^)]*)\)
diff --git a/clang/test/Analysis/check-analyzer-fixit.py b/clang/test/Analysis/check-analyzer-fixit.py
index b616255de89b0..43968f4b1b6e8 100644
--- a/clang/test/Analysis/check-analyzer-fixit.py
+++ b/clang/test/Analysis/check-analyzer-fixit.py
@@ -55,7 +55,7 @@ def run_test_once(args, extra_args):
# themselves. We need to keep the comments to preserve line numbers while
# avoiding empty lines which could potentially trigger formatting-related
# checks.
- cleaned_test = re.sub("// *CHECK-[A-Z0-9\-]*:[^\r\n]*", "//", input_text)
+ cleaned_test = re.sub("// *CHECK-[A-Z0-9\\-]*:[^\r\n]*", "//", input_text)
write_file(temp_file_name, cleaned_test)
original_file_name = temp_file_name + ".orig"
``````````
</details>
https://github.com/llvm/llvm-project/pull/94029
More information about the cfe-commits
mailing list