Skip to content

fix(clang/**.py): fix invalid escape sequences #94029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions clang/docs/tools/dump_ast_matchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,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
Expand All @@ -108,7 +108,7 @@ def extract_result_types(comment):
def strip_doxygen(comment):
"""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.
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/check-analyzer-fixit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cleaned_test = re.sub("// *CHECK-[A-Z0-9\\-]*:[^\r\n]*", "//", input_text)
cleaned_test = re.sub(r"// *CHECK-[A-Z0-9\-]*:[^\r\n]*", "//", input_text)

I would prefer switching to a raw string literal here -- it's functionally equivalent to your change and is more idiomatic to specify a regular expression as a raw string literal.

write_file(temp_file_name, cleaned_test)

original_file_name = temp_file_name + ".orig"
Expand Down