[llvm] [CI] Reduce false positives in UndefGetFormatHelper (PR #134687)
Benjamin Maxwell via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 7 09:55:44 PDT 2025
https://github.com/MacDue created https://github.com/llvm/llvm-project/pull/134687
Only check for diffs containing "undef" in .ll files, this prevents comments like `// We should not have undef values...` triggering the undef bot.
>From 5aea4cc44c97b8afbd889a75d154fb1d0aa97dc7 Mon Sep 17 00:00:00 2001
From: Benjamin Maxwell <benjamin.maxwell at arm.com>
Date: Mon, 7 Apr 2025 16:51:43 +0000
Subject: [PATCH] [CI] Reduce false positives in UndefGetFormatHelper
Only check for diffs containing "undef" in .ll files, this prevents
comments like `// We should not have undef values...` triggering the
undef bot.
---
llvm/utils/git/code-format-helper.py | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/llvm/utils/git/code-format-helper.py b/llvm/utils/git/code-format-helper.py
index cb1e56859d083..d4a7810c9cb84 100755
--- a/llvm/utils/git/code-format-helper.py
+++ b/llvm/utils/git/code-format-helper.py
@@ -376,14 +376,23 @@ def format_run(self, changed_files: List[str], args: FormatArgs) -> Optional[str
sys.stdout.write(proc.stderr)
stdout = proc.stdout
+ if not stdout:
+ return None
+
files = []
+
# Split the diff so we have one array entry per file.
# Each file is prefixed like:
# diff --git a/file b/file
for file in re.split("^diff --git ", stdout, 0, re.MULTILINE):
+ filename = re.match("a/([^ ]+)", file.splitlines()[0])[1]
+ if filename.endswith(".ll"):
+ undef_regex = r"\bundef\b"
+ else:
+ undef_regex = r"UndefValue::get"
# search for additions of undef
- if re.search(r"^[+](?!\s*#\s*).*(\bundef\b|UndefValue::get)", file, re.MULTILINE):
- files.append(re.match("a/([^ ]+)", file.splitlines()[0])[1])
+ if re.search(r"^[+](?!\s*#\s*).*(" + undef_regex + r")", file, re.MULTILINE):
+ files.append(filename)
if not files:
return None
More information about the llvm-commits
mailing list