Skip to content

Commit e1fc118

Browse files
authored
[CI] Reduce false positives in undef checker (#134687)
Only check for diffs containing "undef" in .ll files, this prevents comments like `// We should not have undef values...` triggering the undef checker bot.
1 parent bb50061 commit e1fc118

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

llvm/utils/git/code-format-helper.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,14 +376,25 @@ def format_run(self, changed_files: List[str], args: FormatArgs) -> Optional[str
376376
sys.stdout.write(proc.stderr)
377377
stdout = proc.stdout
378378

379+
if not stdout:
380+
return None
381+
379382
files = []
383+
380384
# Split the diff so we have one array entry per file.
381385
# Each file is prefixed like:
382386
# diff --git a/file b/file
383387
for file in re.split("^diff --git ", stdout, 0, re.MULTILINE):
388+
filename = re.match("a/([^ ]+)", file.splitlines()[0])[1]
389+
if filename.endswith(".ll"):
390+
undef_regex = r"\bundef\b"
391+
else:
392+
undef_regex = r"UndefValue::get"
384393
# search for additions of undef
385-
if re.search(r"^[+](?!\s*#\s*).*(\bundef\b|UndefValue::get)", file, re.MULTILINE):
386-
files.append(re.match("a/([^ ]+)", file.splitlines()[0])[1])
394+
if re.search(
395+
r"^[+](?!\s*#\s*).*(" + undef_regex + r")", file, re.MULTILINE
396+
):
397+
files.append(filename)
387398

388399
if not files:
389400
return None

0 commit comments

Comments
 (0)