|
| 1 | +.. warnings: |
| 2 | +
|
| 3 | +Tools for tracking compiler warnings |
| 4 | +==================================== |
| 5 | + |
| 6 | +.. highlight:: bash |
| 7 | + |
| 8 | +The compiler warning tracking tooling is intended to alert developers about new |
| 9 | +compiler warnings introduced by their contributions. The tooling consists of |
| 10 | +a Python script which is ran by the following GitHub workflows: |
| 11 | + |
| 12 | +* Ubuntu/build and test (:cpy-file:`.github/workflows/reusable-ubuntu.yml`) |
| 13 | +* macOS/build and test (:cpy-file:`.github/workflows/reusable-macos.yml`) |
| 14 | + |
| 15 | +You can check the documentation for the :cpy-file:`Tools/build/check_warnings.py` tool |
| 16 | +by running:: |
| 17 | + |
| 18 | + python Tools/build/check_warnings.py --help |
| 19 | + |
| 20 | +The script can be run locally by providing the compiler output file |
| 21 | +(where the output is saved) and the compiler output type |
| 22 | +(either ``json`` or ``clang``) to see a list of unique warnings:: |
| 23 | + |
| 24 | + python Tools/build/check_warnings.py --compiler-output-file-path=compiler_output.txt --compiler-output-type=json |
| 25 | + |
| 26 | +.. note:: The ``-fdiagnostics-format=json`` flag is required when compiling with GCC |
| 27 | + for the script to properly parse the compiler output. |
| 28 | + |
| 29 | +.. _warning-check-failure: |
| 30 | + |
| 31 | +What to do if a warning check fails GitHub CI |
| 32 | +--------------------------------------------- |
| 33 | + |
| 34 | +The :cpy-file:`Tools/build/check_warnings.py` tool will fail if the compiler generates |
| 35 | +more or less warnings than expected for a given source file as defined in the |
| 36 | +platform-specific warning ignore file. The warning ignore file is either |
| 37 | +:cpy-file:`Tools/build/.warningignore_ubuntu` or |
| 38 | +:cpy-file:`Tools/build/.warningignore_macos` depending on the platform. |
| 39 | + |
| 40 | +If a warning check fails with: |
| 41 | + |
| 42 | +* Unexpected warnings |
| 43 | + * Attempt to refactor the code to avoid the warning. |
| 44 | + * If it is not possible to avoid the warning document in the PR why it is |
| 45 | + reasonable to ignore and add the warning to the platform-specific |
| 46 | + warning ignore file. If the file exists in the warning ignore file |
| 47 | + increment the count by the number of newly introduced warnings. |
| 48 | +* Unexpected improvements (less warnings) |
| 49 | + * Document in the PR that the change reduces the number of compiler |
| 50 | + warnings. Decrement the count in the platform-specific warning |
| 51 | + ignore file or remove the file if the count is now zero. |
0 commit comments