[clang-tools-extra] [clang-tidy] Add an option to exclude files not present in the compile database (PR #120348)

via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 11 09:07:59 PST 2025


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 212cba0ef37dd3b2a253c063240370de42fc67c1...834789678bf967e79c29041452bc96832592de36 clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
``````````

</details>

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

``````````diff
--- clang-tidy-diff.py	2025-01-11 08:49:47.000000 +0000
+++ clang-tidy-diff.py	2025-01-11 17:07:31.260596 +0000
@@ -124,14 +124,16 @@
         # Empty the file:
         open(mergefile, "w").close()
 
 
 def get_compiling_files(args):
-    """ Read a compile_commands.json database and return a set of file paths """
+    """Read a compile_commands.json database and return a set of file paths"""
     current_dir = Path.cwd()
-    compile_commands_json = (current_dir / args.build_path) if args.build_path else current_dir
-    compile_commands_json = (compile_commands_json / "compile_commands.json")
+    compile_commands_json = (
+        (current_dir / args.build_path) if args.build_path else current_dir
+    )
+    compile_commands_json = compile_commands_json / "compile_commands.json"
     files = set()
     with open(compile_commands_json) as db_file:
         db_json = json.load(db_file)
         for entry in db_json:
             if "file" not in entry:
@@ -284,11 +286,14 @@
         else:
             if not re.match("^%s$" % args.iregex, filename, re.IGNORECASE):
                 continue
 
         # Skip any files not in the compiling list
-        if compiling_files is not None and (Path.cwd() / filename) not in compiling_files:
+        if (
+            compiling_files is not None
+            and (Path.cwd() / filename) not in compiling_files
+        ):
             continue
 
         match = re.search(r"^@@.*\+(\d+)(,(\d+))?", line)
         if match:
             start_line = int(match.group(1))

``````````

</details>


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


More information about the cfe-commits mailing list