[llvm] [CI] Reduce false positives in UndefGetFormatHelper (PR #134687)
Benjamin Maxwell via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 7 10:02:00 PDT 2025
https://github.com/MacDue updated https://github.com/llvm/llvm-project/pull/134687
>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 1/2] [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
>From 53b3c182aad37458c3a88afab9b18053fbbf1e34 Mon Sep 17 00:00:00 2001
From: Benjamin Maxwell <benjamin.maxwell at arm.com>
Date: Mon, 7 Apr 2025 17:01:46 +0000
Subject: [PATCH 2/2] Format python
---
llvm/utils/git/code-format-helper.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/llvm/utils/git/code-format-helper.py b/llvm/utils/git/code-format-helper.py
index d4a7810c9cb84..da1b4cdad6978 100755
--- a/llvm/utils/git/code-format-helper.py
+++ b/llvm/utils/git/code-format-helper.py
@@ -391,7 +391,9 @@ def format_run(self, changed_files: List[str], args: FormatArgs) -> Optional[str
else:
undef_regex = r"UndefValue::get"
# search for additions of undef
- if re.search(r"^[+](?!\s*#\s*).*(" + undef_regex + r")", file, re.MULTILINE):
+ if re.search(
+ r"^[+](?!\s*#\s*).*(" + undef_regex + r")", file, re.MULTILINE
+ ):
files.append(filename)
if not files:
More information about the llvm-commits
mailing list