Skip to content

IWYU: Emit stderr when expected output is not found

!8406 (merged) introduced the ability to return a non-zero error code from IWYU invocation if the IWYU command line contains -Xiwyu --error. Unfortunately, this also means that if the file being linted has syntax errors, or otherwise fails to compile, IWYU will return a non-zero error code, which will be propagated by CMake. This failure suppresses invocation of the original compile command with the end result of a silent failure from IWYU and no other error messages.

To avoid this we're now checking for a "success" message from IWYU in addition to suggestions for adding/removing headers. If neither the success string nor add/remove suggestions are found, and IWYU exited with an error code, then we'll display stderr returned from the IWYU invocation so that the user can see why the tool failed.

Edited by Brad King

Merge request reports