Skip to content

Commit 014ab73

Browse files
carlosgalvezpCarlos Gálvez
and
Carlos Gálvez
authored
[clang-tidy] Do not pass any file when listing checks in run_clang_ti… (#137286)
…dy.py Currently, run_clang_tidy.py does not correctly display the list of checks picked up from the top-level .clang-tidy file. The reason for that is that we are passing an empty string as input file. However, that's not how we are supposed to use clang-tidy to list checks. Per 65eccb4, we simply should not pass any file at all - the internal code of clang-tidy will pass a "dummy" file if that's the case and get the .clang-tidy file from the current working directory. Fixes #136659 Co-authored-by: Carlos Gálvez <[email protected]>
1 parent 3d47bc9 commit 014ab73

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

clang-tools-extra/clang-tidy/tool/run-clang-tidy.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def find_compilation_database(path: str) -> str:
8787

8888

8989
def get_tidy_invocation(
90-
f: str,
90+
f: Optional[str],
9191
clang_tidy_binary: str,
9292
checks: str,
9393
tmpdir: Optional[str],
@@ -147,7 +147,8 @@ def get_tidy_invocation(
147147
start.append(f"--warnings-as-errors={warnings_as_errors}")
148148
if allow_no_checks:
149149
start.append("--allow-no-checks")
150-
start.append(f)
150+
if f:
151+
start.append(f)
151152
return start
152153

153154

@@ -490,7 +491,7 @@ async def main() -> None:
490491

491492
try:
492493
invocation = get_tidy_invocation(
493-
"",
494+
None,
494495
clang_tidy_binary,
495496
args.checks,
496497
None,

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ Improvements to clang-tidy
103103
- Fixed bug in :program:`clang-tidy` by which `HeaderFilterRegex` did not take
104104
effect when passed via the `.clang-tidy` file.
105105

106+
- Fixed bug in :program:`run_clang_tidy.py` where the program would not
107+
correctly display the checks enabled by the top-level `.clang-tidy` file.
108+
106109
New checks
107110
^^^^^^^^^^
108111

0 commit comments

Comments
 (0)