[clang] [llvm] Recommit changes to global checks (PR #71171)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 3 04:15:31 PDT 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {darker}-->
:warning: Python code formatter, darker found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
darker --check --diff -r 01689175251f2624fb9d077666657aa21e3f7850..f6c2574edbd1d4fa586b7577149c67cd104d36dc llvm/utils/UpdateTestChecks/common.py llvm/utils/update_cc_test_checks.py llvm/utils/update_test_checks.py
``````````
</details>
<details>
<summary>
View the diff from darker here.
</summary>
``````````diff
--- UpdateTestChecks/common.py 2023-11-03 10:38:04.000000 +0000
+++ UpdateTestChecks/common.py 2023-11-03 11:15:21.113937 +0000
@@ -1686,29 +1686,34 @@
if extract(line, nameless_value)[0] in transitively_visible
]
METADATA_FILTERS = [
- (r"(?<=\")(\w+ )?(\w+ version )[\d.]+(?: \([^)]+\))?", r"{{.*}}\2{{.*}}"), # preface with glob also, to capture optional CLANG_VENDOR
+ (
+ r"(?<=\")(\w+ )?(\w+ version )[\d.]+(?: \([^)]+\))?",
+ r"{{.*}}\2{{.*}}",
+ ), # preface with glob also, to capture optional CLANG_VENDOR
(r'(!DIFile\(filename: ".+", directory: )".+"', r"\1{{.*}}"),
]
-METADATA_FILTERS_RE = [(re.compile(f),r) for (f,r) in METADATA_FILTERS]
+METADATA_FILTERS_RE = [(re.compile(f), r) for (f, r) in METADATA_FILTERS]
def filter_unstable_metadata(line):
- for (f,replacement) in METADATA_FILTERS_RE:
+ for f, replacement in METADATA_FILTERS_RE:
line = f.sub(replacement, line)
return line
+
def flush_current_checks(output_lines, new_lines_w_index, comment_marker):
if not new_lines_w_index:
return
output_lines.append(comment_marker + SEPARATOR)
new_lines_w_index.sort()
for _, line in new_lines_w_index:
output_lines.append(line)
new_lines_w_index.clear()
+
def add_global_checks(
glob_val_dict,
comment_marker,
prefix_list,
@@ -1717,11 +1722,11 @@
preserve_names,
is_before_functions,
global_check_setting,
):
printed_prefixes = set()
- output_lines_loc = {} # Allows GLOB and GLOBNAMED to be sorted correctly
+ output_lines_loc = {} # Allows GLOB and GLOBNAMED to be sorted correctly
for nameless_value in global_nameless_values:
if nameless_value.is_before_functions != is_before_functions:
continue
for p in prefix_list:
global_vars_seen = {}
@@ -1744,11 +1749,14 @@
check_lines = []
global_vars_seen_before = [key for key in global_vars_seen.keys()]
lines_w_index = glob_val_dict[checkprefix][nameless_value.check_prefix]
lines_w_index = filter_globals_according_to_preference(
- lines_w_index, global_vars_seen_before, nameless_value, global_check_setting
+ lines_w_index,
+ global_vars_seen_before,
+ nameless_value,
+ global_check_setting,
)
for i, line in lines_w_index:
if _global_value_regex:
matched = False
for regex in _global_value_regex:
@@ -1769,11 +1777,13 @@
continue
if not checkprefix in output_lines_loc:
output_lines_loc[checkprefix] = []
if not nameless_value.interlaced_with_previous:
- flush_current_checks(output_lines, output_lines_loc[checkprefix], comment_marker)
+ flush_current_checks(
+ output_lines, output_lines_loc[checkprefix], comment_marker
+ )
for check_line in check_lines:
output_lines_loc[checkprefix].append(check_line)
printed_prefixes.add((checkprefix, nameless_value.check_prefix))
@@ -1788,11 +1798,13 @@
if p[0] is None:
continue
for checkprefix in p[0]:
if checkprefix not in output_lines_loc:
continue
- flush_current_checks(output_lines, output_lines_loc[checkprefix], comment_marker)
+ flush_current_checks(
+ output_lines, output_lines_loc[checkprefix], comment_marker
+ )
break
output_lines.append(comment_marker + SEPARATOR)
return printed_prefixes
--- update_cc_test_checks.py 2023-11-03 10:35:29.000000 +0000
+++ update_cc_test_checks.py 2023-11-03 11:15:21.389578 +0000
@@ -437,11 +437,11 @@
func,
global_vars_seen_dict,
is_filtered=builder.is_filtered(),
)
- if ti.args.check_globals != 'none':
+ if ti.args.check_globals != "none":
generated_prefixes.extend(
common.add_global_checks(
builder.global_var_dict(),
"//",
run_list,
@@ -495,11 +495,11 @@
# Remove the comment line since we will generate a new comment
# line as part of common.add_ir_checks()
output_lines.pop()
last_line = output_lines[-1].strip()
if (
- ti.args.check_globals != 'none'
+ ti.args.check_globals != "none"
and not has_checked_pre_function_globals
):
generated_prefixes.extend(
common.add_global_checks(
builder.global_var_dict(),
@@ -534,11 +534,11 @@
include_line = False
if include_line:
output_lines.append(line.rstrip("\n"))
- if ti.args.check_globals != 'none':
+ if ti.args.check_globals != "none":
generated_prefixes.extend(
common.add_global_checks(
builder.global_var_dict(),
"//",
run_list,
--- update_test_checks.py 2023-11-03 10:35:29.000000 +0000
+++ update_test_checks.py 2023-11-03 11:15:21.587628 +0000
@@ -196,11 +196,11 @@
# be sure the input function order is maintained. Therefore, first spit
# out all the source lines.
common.dump_input_lines(output_lines, ti, prefix_set, ";")
args = ti.args
- if args.check_globals != 'none':
+ if args.check_globals != "none":
generated_prefixes.extend(
common.add_global_checks(
builder.global_var_dict(),
";",
prefix_list,
@@ -304,11 +304,11 @@
if args.function is not None and func_name != args.function:
# When filtering on a specific function, skip all others.
continue
is_in_function = is_in_function_start = True
- if args.check_globals != 'none':
+ if args.check_globals != "none":
generated_prefixes.extend(
common.add_global_checks(
builder.global_var_dict(),
";",
prefix_list,
``````````
</details>
https://github.com/llvm/llvm-project/pull/71171
More information about the llvm-commits
mailing list