Skip to content

IWYU: Return error code if user enables error reporting

Ashish Sadanandan requested to merge praetorian20/cmake:iwyu_errors into master

CMake currently ignores the return code from iwyu because old versions of the tool would exit with an error code even when no header include violations were detected. The iwyu project has since changed this behavior, so the tool no longer returns an error code unless the user enables error reporting via command line arguments.

Behavior seen with iwyu version 0.19

Source file with missing includes:

  • Case 1: iwyu arguments:
    • return code: 0
    • output:
  • Case 2: iwyu arguments: -Xiwyu --error
    • return code: 1
    • output:

Source file with no missing includes:

  • Case 1: iwyu arguments:
    • return code: 0
    • output: (/path/to/file.cc has correct #includes/fwd-decls)
  • Case 2: iwyu arguments: -Xiwyu --error
    • return code: 0
    • output: (/path/to/file.cc has correct #includes/fwd-decls)

This commit updates CMake behavior to return the iwyu return code if the user has invoked the tool with any of these command line arguments included:

  • --error[=N]
  • --error_always[=N]

Fixes: #24066 (closed)

Edited by Brad King

Merge request reports