[llvm] Reduce false positives in ids-check workflow (PR #194878)

via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 29 08:08:23 PDT 2026


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 origin/main...HEAD llvm/utils/git/ids-check-helper.py
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from darker here.
</summary>

``````````diff
--- ids-check-helper.py	2026-04-29 15:05:27.000000 +0000
+++ ids-check-helper.py	2026-04-29 15:07:47.471640 +0000
@@ -51,91 +51,80 @@
     # PDB DIA requires Windows ATL (atlbase.h), unbuildable on Linux runners.
     "llvm/include/llvm/DebugInfo/PDB/DIA/",
     # No in-tree non-tools/non-target source #includes these headers, so we
     # can't run idt on a TU that pulls them in.
     "llvm/include/llvm/ExecutionEngine/Interpreter.h",  # only lli.cpp
-    "llvm/include/llvm/Support/DebugLog.h",             # only lib/Target/RISCV/
-    "llvm/include/llvm/Support/TargetSelect.h",         # only target-registration sources
+    "llvm/include/llvm/Support/DebugLog.h",  # only lib/Target/RISCV/
+    "llvm/include/llvm/Support/TargetSelect.h",  # only target-registration sources
 ]
 
 
 # Manual header -> source mappings for headers that don't fit the conventional
 # `llvm/include/llvm/<Subsystem>/<Bar>.h` -> `llvm/lib/<Subsystem>/<Bar>.cpp`
 # layout. Used when neither the direct mapping nor the same-subdirectory
 # grep fallback finds a workable source.
 HEADER_SOURCE_OVERRIDES = {
     # LLVM-C headers
-    "llvm/include/llvm-c/Analysis.h":          "llvm/lib/Analysis/Analysis.cpp",
-    "llvm/include/llvm-c/BitReader.h":         "llvm/lib/Bitcode/Reader/BitReader.cpp",
-    "llvm/include/llvm-c/BitWriter.h":         "llvm/lib/Bitcode/Writer/BitWriter.cpp",
-    "llvm/include/llvm-c/Comdat.h":            "llvm/lib/IR/Comdat.cpp",
-    "llvm/include/llvm-c/Core.h":              "llvm/lib/IR/Core.cpp",
-    "llvm/include/llvm-c/DebugInfo.h":         "llvm/lib/IR/DebugInfo.cpp",
-    "llvm/include/llvm-c/Disassembler.h":      "llvm/lib/MC/MCDisassembler/Disassembler.cpp",
-    "llvm/include/llvm-c/ErrorHandling.h":     "llvm/lib/Support/ErrorHandling.cpp",
-    "llvm/include/llvm-c/ExecutionEngine.h":   "llvm/lib/ExecutionEngine/ExecutionEngineBindings.cpp",
-    "llvm/include/llvm-c/IRReader.h":          "llvm/lib/IRReader/IRReader.cpp",
-    "llvm/include/llvm-c/LLJIT.h":             "llvm/lib/ExecutionEngine/Orc/LLJITUtilsCBindings.cpp",
-    "llvm/include/llvm-c/LLJITUtils.h":        "llvm/lib/ExecutionEngine/Orc/Debugging/LLJITUtilsCBindings.cpp",
-    "llvm/include/llvm-c/Linker.h":            "llvm/lib/Linker/LinkModules.cpp",
-    "llvm/include/llvm-c/Object.h":            "llvm/lib/Object/Object.cpp",
-    "llvm/include/llvm-c/Orc.h":               "llvm/lib/ExecutionEngine/Orc/OrcV2CBindings.cpp",
-    "llvm/include/llvm-c/OrcEE.h":             "llvm/lib/ExecutionEngine/Orc/OrcV2CBindings.cpp",
-    "llvm/include/llvm-c/Remarks.h":           "llvm/lib/Remarks/RemarkParser.cpp",
-    "llvm/include/llvm-c/Support.h":           "llvm/lib/Support/CommandLine.cpp",
-    "llvm/include/llvm-c/Target.h":            "llvm/lib/Target/Target.cpp",
-    "llvm/include/llvm-c/TargetMachine.h":     "llvm/lib/Target/TargetMachineC.cpp",
+    "llvm/include/llvm-c/Analysis.h": "llvm/lib/Analysis/Analysis.cpp",
+    "llvm/include/llvm-c/BitReader.h": "llvm/lib/Bitcode/Reader/BitReader.cpp",
+    "llvm/include/llvm-c/BitWriter.h": "llvm/lib/Bitcode/Writer/BitWriter.cpp",
+    "llvm/include/llvm-c/Comdat.h": "llvm/lib/IR/Comdat.cpp",
+    "llvm/include/llvm-c/Core.h": "llvm/lib/IR/Core.cpp",
+    "llvm/include/llvm-c/DebugInfo.h": "llvm/lib/IR/DebugInfo.cpp",
+    "llvm/include/llvm-c/Disassembler.h": "llvm/lib/MC/MCDisassembler/Disassembler.cpp",
+    "llvm/include/llvm-c/ErrorHandling.h": "llvm/lib/Support/ErrorHandling.cpp",
+    "llvm/include/llvm-c/ExecutionEngine.h": "llvm/lib/ExecutionEngine/ExecutionEngineBindings.cpp",
+    "llvm/include/llvm-c/IRReader.h": "llvm/lib/IRReader/IRReader.cpp",
+    "llvm/include/llvm-c/LLJIT.h": "llvm/lib/ExecutionEngine/Orc/LLJITUtilsCBindings.cpp",
+    "llvm/include/llvm-c/LLJITUtils.h": "llvm/lib/ExecutionEngine/Orc/Debugging/LLJITUtilsCBindings.cpp",
+    "llvm/include/llvm-c/Linker.h": "llvm/lib/Linker/LinkModules.cpp",
+    "llvm/include/llvm-c/Object.h": "llvm/lib/Object/Object.cpp",
+    "llvm/include/llvm-c/Orc.h": "llvm/lib/ExecutionEngine/Orc/OrcV2CBindings.cpp",
+    "llvm/include/llvm-c/OrcEE.h": "llvm/lib/ExecutionEngine/Orc/OrcV2CBindings.cpp",
+    "llvm/include/llvm-c/Remarks.h": "llvm/lib/Remarks/RemarkParser.cpp",
+    "llvm/include/llvm-c/Support.h": "llvm/lib/Support/CommandLine.cpp",
+    "llvm/include/llvm-c/Target.h": "llvm/lib/Target/Target.cpp",
+    "llvm/include/llvm-c/TargetMachine.h": "llvm/lib/Target/TargetMachineC.cpp",
     "llvm/include/llvm-c/Transforms/PassBuilder.h": "llvm/lib/Passes/PassBuilderBindings.cpp",
-    "llvm/include/llvm-c/Types.h":             "llvm/lib/IR/Core.cpp",
-    "llvm/include/llvm-c/lto.h":               "llvm/tools/lto/lto.cpp",
-
+    "llvm/include/llvm-c/Types.h": "llvm/lib/IR/Core.cpp",
+    "llvm/include/llvm-c/lto.h": "llvm/tools/lto/lto.cpp",
     # Top-level llvm/ headers
-    "llvm/include/llvm/Pass.h":                "llvm/lib/IR/Pass.cpp",
+    "llvm/include/llvm/Pass.h": "llvm/lib/IR/Pass.cpp",
     "llvm/include/llvm/PassAnalysisSupport.h": "llvm/lib/IR/Pass.cpp",
-    "llvm/include/llvm/PassRegistry.h":        "llvm/lib/IR/PassRegistry.cpp",
-    "llvm/include/llvm/PassSupport.h":         "llvm/lib/IR/Pass.cpp",
-    "llvm/include/llvm/InitializePasses.h":    "llvm/lib/Analysis/Analysis.cpp",
-    "llvm/include/llvm/LinkAllIR.h":           "llvm/lib/IR/Core.cpp",
-    "llvm/include/llvm/LinkAllPasses.h":       "llvm/lib/IR/Pass.cpp",
-
+    "llvm/include/llvm/PassRegistry.h": "llvm/lib/IR/PassRegistry.cpp",
+    "llvm/include/llvm/PassSupport.h": "llvm/lib/IR/Pass.cpp",
+    "llvm/include/llvm/InitializePasses.h": "llvm/lib/Analysis/Analysis.cpp",
+    "llvm/include/llvm/LinkAllIR.h": "llvm/lib/IR/Core.cpp",
+    "llvm/include/llvm/LinkAllPasses.h": "llvm/lib/IR/Pass.cpp",
     # Headers under llvm/include/llvm/Target/ whose same-subdir grep fallback
     # picks per-target sources (e.g. X86, AArch64). Redirect to lib/CodeGen/
     # sources.
     "llvm/include/llvm/Target/CGPassBuilderOption.h": "llvm/lib/CodeGen/TargetPassConfig.cpp",
-    "llvm/include/llvm/Target/TargetOptions.h":       "llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp",
-
+    "llvm/include/llvm/Target/TargetOptions.h": "llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp",
     # Headers pulled in transitively by a small set of "umbrella" sources.
-    "llvm/include/llvm/ADT/ilist_node_base.h":                    "llvm/lib/CodeGen/CodeGenPrepare.cpp",
-    "llvm/include/llvm/Analysis/SimplifyQuery.h":                 "llvm/lib/CodeGen/CodeGenPrepare.cpp",
-    "llvm/include/llvm/CodeGenTypes/MachineValueType.h":          "llvm/lib/CodeGen/CodeGenPrepare.cpp",
-    "llvm/include/llvm/IR/Analysis.h":                            "llvm/lib/CodeGen/CodeGenPrepare.cpp",
-    "llvm/include/llvm/IR/ConstantFolder.h":                      "llvm/lib/CodeGen/CodeGenPrepare.cpp",
-    "llvm/include/llvm/IR/FMF.h":                                 "llvm/lib/CodeGen/CodeGenPrepare.cpp",
-    "llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h":  "llvm/lib/CodeGen/CodeGenPrepare.cpp",
-    "llvm/include/llvm/IR/IRBuilderFolder.h":                     "llvm/lib/CodeGen/CodeGenPrepare.cpp",
-    "llvm/include/llvm/Support/Recycler.h":                       "llvm/lib/CodeGen/CodeGenPrepare.cpp",
-    "llvm/include/llvm-c/Error.h":                                "llvm/lib/CodeGen/CodeGenPrepare.cpp",
-    "llvm/include/llvm-c/Visibility.h":                           "llvm/lib/CodeGen/CodeGenPrepare.cpp",
-
+    "llvm/include/llvm/ADT/ilist_node_base.h": "llvm/lib/CodeGen/CodeGenPrepare.cpp",
+    "llvm/include/llvm/Analysis/SimplifyQuery.h": "llvm/lib/CodeGen/CodeGenPrepare.cpp",
+    "llvm/include/llvm/CodeGenTypes/MachineValueType.h": "llvm/lib/CodeGen/CodeGenPrepare.cpp",
+    "llvm/include/llvm/IR/Analysis.h": "llvm/lib/CodeGen/CodeGenPrepare.cpp",
+    "llvm/include/llvm/IR/ConstantFolder.h": "llvm/lib/CodeGen/CodeGenPrepare.cpp",
+    "llvm/include/llvm/IR/FMF.h": "llvm/lib/CodeGen/CodeGenPrepare.cpp",
+    "llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": "llvm/lib/CodeGen/CodeGenPrepare.cpp",
+    "llvm/include/llvm/IR/IRBuilderFolder.h": "llvm/lib/CodeGen/CodeGenPrepare.cpp",
+    "llvm/include/llvm/Support/Recycler.h": "llvm/lib/CodeGen/CodeGenPrepare.cpp",
+    "llvm/include/llvm-c/Error.h": "llvm/lib/CodeGen/CodeGenPrepare.cpp",
+    "llvm/include/llvm-c/Visibility.h": "llvm/lib/CodeGen/CodeGenPrepare.cpp",
     # DTLTO drags in Any/LTO/FormatVariadic.
-    "llvm/include/llvm/ADT/Any.h":                                "llvm/lib/DTLTO/DTLTO.cpp",
-    "llvm/include/llvm/LTO/Config.h":                             "llvm/lib/DTLTO/DTLTO.cpp",
-    "llvm/include/llvm/Support/FormatVariadicDetails.h":          "llvm/lib/DTLTO/DTLTO.cpp",
-
+    "llvm/include/llvm/ADT/Any.h": "llvm/lib/DTLTO/DTLTO.cpp",
+    "llvm/include/llvm/LTO/Config.h": "llvm/lib/DTLTO/DTLTO.cpp",
+    "llvm/include/llvm/Support/FormatVariadicDetails.h": "llvm/lib/DTLTO/DTLTO.cpp",
     # Orc debugging / executor-side helpers.
-    "llvm/include/llvm/DebugInfo/DWARF/LowLevel/DWARFDataExtractorSimple.h":
-        "llvm/lib/ExecutionEngine/Orc/Debugging/DebugInfoSupport.cpp",
-    "llvm/include/llvm/ExecutionEngine/Orc/MaterializationUnit.h":
-        "llvm/lib/ExecutionEngine/Orc/Debugging/DebugInfoSupport.cpp",
-    "llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/ExecutorBootstrapService.h":
-        "llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp",
-    "llvm/include/llvm-c/blake3.h":
-        "llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp",
-
+    "llvm/include/llvm/DebugInfo/DWARF/LowLevel/DWARFDataExtractorSimple.h": "llvm/lib/ExecutionEngine/Orc/Debugging/DebugInfoSupport.cpp",
+    "llvm/include/llvm/ExecutionEngine/Orc/MaterializationUnit.h": "llvm/lib/ExecutionEngine/Orc/Debugging/DebugInfoSupport.cpp",
+    "llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/ExecutorBootstrapService.h": "llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp",
+    "llvm/include/llvm-c/blake3.h": "llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp",
     # AsmPrinter handler shim.
-    "llvm/include/llvm/CodeGen/AsmPrinterHandler.h":
-        "llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp",
+    "llvm/include/llvm/CodeGen/AsmPrinterHandler.h": "llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp",
 }
 
 
 # When the include subdir doesn't match a lib subdir, redirect lookups.
 # ADT is mostly templates and has no `llvm/lib/ADT/` — the few non-inline
@@ -321,13 +310,11 @@
 
             filtered.append(path)
 
         return filtered
 
-    def find_source_for_header(
-        self, header: str, args: IdsCheckArgs
-    ) -> Optional[str]:
+    def find_source_for_header(self, header: str, args: IdsCheckArgs) -> Optional[str]:
         """Return a source file (relative path) that includes the given header,
         or None if no good match. We need a source because LLVM doesn't list
         headers in compile_commands.json — running idt on a header directly
         produces wrong AST (no compile command, default flags).
 
@@ -344,32 +331,33 @@
         if header in HEADER_SOURCE_OVERRIDES:
             return HEADER_SOURCE_OVERRIDES[header]
 
         # 2. Direct mapping.
         if header.startswith("llvm/include/llvm/"):
-            sub = header[len("llvm/include/llvm/"):]
+            sub = header[len("llvm/include/llvm/") :]
             first_part, _, rest = sub.partition("/")
             remap = INCLUDE_TO_LIB_SUBDIR.get(first_part)
             sub_remapped = f"{remap}/{rest}" if remap and rest else sub
             for ext in (".cpp", ".cc"):
                 candidate = Path("llvm/lib") / Path(sub_remapped).with_suffix(ext)
                 if candidate.exists():
                     return str(candidate)
 
         # 3. Same-subdirectory grep fallback.
         if header.startswith("llvm/include/llvm/"):
-            sub = header[len("llvm/include/llvm/"):]
+            sub = header[len("llvm/include/llvm/") :]
             first_part = sub.split("/")[0]
             first_part = INCLUDE_TO_LIB_SUBDIR.get(first_part, first_part)
             lib_subdir = f"llvm/lib/{first_part}"
             if Path(lib_subdir).is_dir():
                 inc = header.removeprefix("llvm/include/")
                 try:
                     result = subprocess.run(
-                        ["git", "grep", "-l", f'#include "{inc}"',
-                         "--", lib_subdir],
-                        capture_output=True, text=True, timeout=15,
+                        ["git", "grep", "-l", f'#include "{inc}"', "--", lib_subdir],
+                        capture_output=True,
+                        text=True,
+                        timeout=15,
                     )
                 except subprocess.TimeoutExpired:
                     return None
                 if result.returncode == 0 and result.stdout:
                     for line in result.stdout.splitlines():
@@ -413,50 +401,57 @@
                     print(f"  Skipping {header}: no matching source", file=sys.stderr)
                 continue
 
             cmd = [
                 idt_path,
-                "-p", compile_commands,
+                "-p",
+                compile_commands,
                 "--apply-fixits",
                 "--inplace",
                 f"--export-macro={category['export_macro']}",
                 f"--include-header={category['include_header']}",
                 f"--extra-arg=-D{category['export_macro']}={self.MACRO_DEFINITION}",
                 "--extra-arg=-Wno-macro-redefined",
             ]
 
             for prefix in category.get("system_header_prefixes", []):
-                cmd += ["--extra-arg=-Xclang",
-                        f"--extra-arg=--system-header-prefix={prefix}"]
+                cmd += [
+                    "--extra-arg=-Xclang",
+                    f"--extra-arg=--system-header-prefix={prefix}",
+                ]
             for prefix in category.get("no_system_header_prefixes", []):
-                cmd += ["--extra-arg=-Xclang",
-                        f"--extra-arg=--no-system-header-prefix={prefix}"]
+                cmd += [
+                    "--extra-arg=-Xclang",
+                    f"--extra-arg=--no-system-header-prefix={prefix}",
+                ]
             cmd.append(source)
 
             if args.verbose:
-                print(f"Running on source {source} for header {header}",
-                      file=sys.stderr)
+                print(
+                    f"Running on source {source} for header {header}", file=sys.stderr
+                )
 
             subprocess.run(cmd)
 
             # Post-filter: revert any modifications to files outside this
             # category. idt may have touched private llvm/lib/* implementation
             # headers (which it shouldn't — they aren't part of the public ABI)
             # or other-category headers via paths that escaped the prefix
             # filter. Drop those.
             modified = subprocess.run(
                 ["git", "diff", "--name-only"],
-                capture_output=True, text=True,
+                capture_output=True,
+                text=True,
             ).stdout.splitlines()
             revert = [
-                f for f in modified
+                f
+                for f in modified
                 if not f.startswith(category_prefix)
                 or any(f.startswith(ex) for ex in category_excludes)
             ]
             if revert:
-                subprocess.run(["git", "checkout", "--"] + revert,
-                               capture_output=True)
+                subprocess.run(["git", "checkout", "--"] + revert, capture_output=True)
 
         return True
 
     def get_changed_files(self, args: IdsCheckArgs) -> List[str]:
         """Get list of changed files between revisions."""

``````````

</details>


https://github.com/llvm/llvm-project/pull/194878


More information about the llvm-commits mailing list