Skip to content

[clang-tidy] fix add_new_check.py regex #89189

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

Merged
merged 1 commit into from
Apr 18, 2024
Merged
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
12 changes: 6 additions & 6 deletions clang-tools-extra/clang-tidy/add_new_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def adapt_module(module_path, module, check_name, check_name_camel):
f.write(check_decl)
else:
match = re.search(
'registerCheck<(.*)> *\( *(?:"([^"]*)")?', line
r'registerCheck<(.*)> *\( *(?:"([^"]*)")?', line
)
prev_line = None
if match:
Expand Down Expand Up @@ -383,7 +383,7 @@ def filename_from_module(module_name, check_name):
if stmt_start_pos == -1:
return ""
stmt = code[stmt_start_pos + 1 : stmt_end_pos]
matches = re.search('registerCheck<([^>:]*)>\(\s*"([^"]*)"\s*\)', stmt)
matches = re.search(r'registerCheck<([^>:]*)>\(\s*"([^"]*)"\s*\)', stmt)
if matches and matches[2] == full_check_name:
class_name = matches[1]
if "::" in class_name:
Expand All @@ -401,8 +401,8 @@ def filename_from_module(module_name, check_name):
# Examine code looking for a c'tor definition to get the base class name.
def get_base_class(code, check_file):
check_class_name = os.path.splitext(os.path.basename(check_file))[0]
ctor_pattern = check_class_name + "\([^:]*\)\s*:\s*([A-Z][A-Za-z0-9]*Check)\("
matches = re.search("\s+" + check_class_name + "::" + ctor_pattern, code)
ctor_pattern = check_class_name + r"\([^:]*\)\s*:\s*([A-Z][A-Za-z0-9]*Check)\("
matches = re.search(r"\s+" + check_class_name + "::" + ctor_pattern, code)

# The constructor might be inline in the header.
if not matches:
Expand Down Expand Up @@ -476,7 +476,7 @@ def process_doc(doc_file):
# Orphan page, don't list it.
return "", ""

match = re.search(".*:http-equiv=refresh: \d+;URL=(.*).html(.*)", content)
match = re.search(r".*:http-equiv=refresh: \d+;URL=(.*).html(.*)", content)
# Is it a redirect?
return check_name, match

Expand Down Expand Up @@ -505,7 +505,7 @@ def format_link_alias(doc_file):
ref_begin = ""
ref_end = "_"
else:
redirect_parts = re.search("^\.\./([^/]*)/([^/]*)$", match.group(1))
redirect_parts = re.search(r"^\.\./([^/]*)/([^/]*)$", match.group(1))
title = redirect_parts[1] + "-" + redirect_parts[2]
target = redirect_parts[1] + "/" + redirect_parts[2]
autofix = has_auto_fix(title)
Expand Down