Skip to content

Commit 71d1335

Browse files
committed
upd iwyu.py
upd iwyu.py commit_hash:165bbb355494ae71e5a8873248ba461cf802d004
1 parent 9130190 commit 71d1335

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

build/scripts/iwyu.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ def run_iwyu_command(iwyu_bin: str, filtered_clang_cmd: List[str], verbose: str,
408408
f"--verbose={verbose}",
409409
"--cxx17ns",
410410
"--no_fwd_decls",
411+
"--error",
411412
):
412413
cmd.extend(["-Xiwyu", arg])
413414
return subprocess.Popen(stdout=subprocess.PIPE, stderr=subprocess.PIPE, args=cmd)
@@ -444,6 +445,19 @@ def main() -> None:
444445
process = run_iwyu_command(args.iwyu_bin, filtered_clang_cmd, DEFAULT_VERBOSE_LEVEL, mapping_file)
445446
iwyu_raw_stdout, iwyu_raw_stderr = process.communicate()
446447
stderr = iwyu_raw_stderr.decode("utf-8", errors="replace")
448+
iwyu_raw_stdout = iwyu_raw_stdout.decode("utf-8", errors="replace")
449+
450+
# For developer: iwyu errors
451+
if iwyu_raw_stdout:
452+
result = {
453+
"file": testing_src,
454+
"exit_code": 1,
455+
"stderr": iwyu_raw_stdout,
456+
"stdout": iwyu_raw_stdout,
457+
}
458+
with open(args.iwyu_json, "w") as fh:
459+
json.dump(result, fh, indent=2)
460+
return
447461

448462
verbose_text, raw_suggestions = separate_verbose_from_suggestions(stderr)
449463

@@ -456,8 +470,6 @@ def main() -> None:
456470
"exit_code": 1,
457471
"stderr": err_norm,
458472
"stdout": err_norm,
459-
"iwyu_raw_stdout": iwyu_raw_stdout.decode(errors="replace"),
460-
"iwyu_raw_stderr": iwyu_raw_stderr.decode(errors="replace"),
461473
}
462474
else:
463475
result = {
@@ -487,8 +499,6 @@ def main() -> None:
487499
"exit_code": 0 if not iwyu_clean_output.strip() else 1,
488500
"stderr": iwyu_stderr,
489501
"stdout": iwyu_clean_output,
490-
"iwyu_raw_stdout": iwyu_raw_stdout.decode(errors="replace"),
491-
"iwyu_raw_stderr": iwyu_raw_stderr.decode(errors="replace"),
492502
}
493503
with open(args.iwyu_json, "w") as fh:
494504
json.dump(result, fh, indent=2)

0 commit comments

Comments
 (0)