diff options
author | Henrik G. Olsson <hnrklssn@gmail.com> | 2024-02-28 17:08:36 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-28 17:08:36 -0800 |
commit | 6a65b44322ee7ba816283c31f8d71559592ca5e7 (patch) | |
tree | 34cd260b3794f6c7c1276dc3c282101c3280ec7a /llvm/utils/UpdateTestChecks/common.py | |
parent | 2679d3793b264b2884cf5c9492e3311f08f41de3 (diff) | |
download | llvm-6a65b44322ee7ba816283c31f8d71559592ca5e7.zip llvm-6a65b44322ee7ba816283c31f8d71559592ca5e7.tar.gz llvm-6a65b44322ee7ba816283c31f8d71559592ca5e7.tar.bz2 |
[UTC] Don't leave dangling CHECK-SAME when removing CHECK lines (#82569)
When removing only lines that are global value CHECK lines, a related
CHECK-SAME line could be left dangling without a previous line to belong
to.
Resolves #78517
Diffstat (limited to 'llvm/utils/UpdateTestChecks/common.py')
-rw-r--r-- | llvm/utils/UpdateTestChecks/common.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py index 4a02a92..5377752 100644 --- a/llvm/utils/UpdateTestChecks/common.py +++ b/llvm/utils/UpdateTestChecks/common.py @@ -388,7 +388,12 @@ def itertests( def should_add_line_to_output( - input_line, prefix_set, skip_global_checks=False, comment_marker=";" + input_line, + prefix_set, + *, + skip_global_checks=False, + skip_same_checks=False, + comment_marker=";", ): # Skip any blank comment lines in the IR. if not skip_global_checks and input_line.strip() == comment_marker: @@ -402,9 +407,14 @@ def should_add_line_to_output( # And skip any CHECK lines. We're building our own. m = CHECK_RE.match(input_line) if m and m.group(1) in prefix_set: + if skip_same_checks and CHECK_SAME_RE.match(input_line): + # The previous CHECK line was removed, so don't leave this dangling + return False if skip_global_checks: + # Skip checks only if they are of global value definitions global_ir_value_re = re.compile(r"(\[\[|@)", flags=(re.M)) - return not global_ir_value_re.search(input_line) + is_global = global_ir_value_re.search(input_line) + return not is_global return False return True @@ -483,6 +493,7 @@ PREFIX_RE = re.compile("^[a-zA-Z0-9_-]+$") CHECK_RE = re.compile( r"^\s*(?://|[;#])\s*([^:]+?)(?:-NEXT|-NOT|-DAG|-LABEL|-SAME|-EMPTY)?:" ) +CHECK_SAME_RE = re.compile(r"^\s*(?://|[;#])\s*([^:]+?)(?:-SAME)?:") UTC_ARGS_KEY = "UTC_ARGS:" UTC_ARGS_CMD = re.compile(r".*" + UTC_ARGS_KEY + r"\s*(?P<cmd>.*)\s*$") |