Skip to content

Commit c444713

Browse files
committed
Filter iwyu implementation detail header suggestions on macOS
Newer iwyu versions on macOS suggest implementation detail headers (starting with __). Filter entire output when all suggestions are for implementation headers.
1 parent 1834c53 commit c444713

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/test_hooks.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,15 @@ def run_shell_cmd(cmd_name, files, args, _, target_output, target_retcode):
555555
# Windows clang uses return-mismatch instead of return-type
556556
if cmd_name in ["clang-tidy", "include-what-you-use"]:
557557
actual = actual.replace(b"clang-diagnostic-return-mismatch", b"clang-diagnostic-return-type")
558+
# Filter iwyu suggestions for implementation detail headers on macOS
559+
if cmd_name == "include-what-you-use" and sys.platform == "darwin":
560+
# Remove entire iwyu output if it only suggests implementation detail headers (starting with __)
561+
lines = actual.split(b"\n")
562+
# Check if all suggested headers are implementation details
563+
suggested_headers = [l for l in lines if l.strip().startswith(b"#include <__")]
564+
if suggested_headers and all(b"<__" in l for l in lines if b"#include <" in l and l.strip().startswith(b"#include")):
565+
# All suggestions are for implementation headers - filter entire output
566+
actual = b""
558567
retcode = sp_child.returncode
559568
utils.assert_equal(target_output, actual)
560569
assert target_retcode == retcode

0 commit comments

Comments
 (0)