Files
odfstudio/compilerplugins
Michael Weghorn 5d72f86b56 Ignore loplugin:pointerbool/implicitboolconversion for some soltools C programs
For now, disable these two clang plugins for C sources of
2 build tools in soltools. Otherwise, these were newly seen
triggering/failing the build after a glibc update on Debian testing
from 2.42-17 to 2.43-3:

    /home/michi/development/git/libreoffice/soltools/mkdepend/include.c:259:12: error: implicit conversion (IntegralToBoolean) of call argument from 'int' to 'bool' [loplugin:implicitboolconversion]
      259 |     assert(n < BUFSIZ);
          |     ~~~~~~~^~~~~~~~~~~
    /usr/include/assert.h:157:42: note: expanded from macro 'assert'
      157 |     ((void) sizeof (__assert_single_arg (__VA_ARGS__)), __extension__ ({ \
          |                                          ^~~~~~~~~~~
    1 error generated.
    make[1]: *** [/home/michi/development/git/libreoffice/solenv/gbuild/LinkTarget.mk:278: /home/michi/development/git/libreoffice/workdir/CObject/soltools/mkdepend/include.o] Error 1
    make[1]: *** Waiting for unfinished jobs....
    /home/michi/development/git/libreoffice/soltools/cpp/_tokens.c:56:17: error: possibly unwanted implicit conversion when calling bool param [loplugin:pointerbool]
       56 |     assert(trp->bp); // realloc failure is OOM -> no point to handle
          |            ~~~~~^~
    /usr/include/assert.h:157:42: note: expanded from macro 'assert'
      157 |     ((void) sizeof (__assert_single_arg (__VA_ARGS__)), __extension__ ({ \
          |                                          ^~~~~~~~~~~
    /usr/include/assert.h:117:40: note: method here [loplugin:pointerbool]
      117 | extern _Bool __assert_single_arg (_Bool);
          |                                   ~~~~~^
    /home/michi/development/git/libreoffice/soltools/cpp/_tokens.c:56:12: error: implicit conversion (PointerToBoolean) of call argument from 'Token *' (aka 'struct token *') to 'bool' [loplugin:implicitboolconversion]
       56 |     assert(trp->bp); // realloc failure is OOM -> no point to handle
          |            ^~~~~~~
    /usr/include/assert.h:157:42: note: expanded from macro 'assert'
      157 |     ((void) sizeof (__assert_single_arg (__VA_ARGS__)), __extension__ ({ \
          |                                          ^~~~~~~~~~~
    2 errors generated.
    make[1]: *** [/home/michi/development/git/libreoffice/solenv/gbuild/LinkTarget.mk:278: /home/michi/development/git/libreoffice/workdir/CObject/soltools/cpp/_tokens.o] Error 1
    /home/michi/development/git/libreoffice/soltools/mkdepend/main.c:525:12: error: possibly unwanted implicit conversion when calling bool param [loplugin:pointerbool]
      525 |     assert(p); // Don't handle OOM conditions
          |            ^
    /usr/include/assert.h:117:40: note: method here [loplugin:pointerbool]
      117 | extern _Bool __assert_single_arg (_Bool);
          |                                   ~~~~~^
    /home/michi/development/git/libreoffice/soltools/mkdepend/main.c:730:16: error: possibly unwanted implicit conversion when calling bool param [loplugin:pointerbool]
      730 |         assert(new_string); // Don't handle OOM conditions
          |                ^~~~~~~~~~
    /usr/include/assert.h:117:40: note: method here [loplugin:pointerbool]
      117 | extern _Bool __assert_single_arg (_Bool);
          |                                   ~~~~~^
    /home/michi/development/git/libreoffice/soltools/mkdepend/main.c:525:12: error: implicit conversion (PointerToBoolean) of call argument from 'char *' to 'bool' [loplugin:implicitboolconversion]
      525 |     assert(p); // Don't handle OOM conditions
          |            ^
    /home/michi/development/git/libreoffice/soltools/mkdepend/main.c:730:16: error: implicit conversion (PointerToBoolean) of call argument from 'char *' to 'bool' [loplugin:implicitboolconversion]
      730 |         assert(new_string); // Don't handle OOM conditions
          |                ^~~~~~~~~~
    4 errors generated.

Change-Id: Icc11df58e8ae4f092bb4c4147bfdfad1b53ffff5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209872
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2026-08-26 11:39:07 +02:00
..
2026-01-02 19:28:56 +01:00
…
…

Compiler plugins

Overview

This directory contains code for compiler plugins. These are used to perform additional actions during compilation (such as additional warnings) and also to perform mass code refactoring.

Currently only the Clang compiler is supported http://wiki.documentfoundation.org/Development/Clang.

Usage

Compiler plugins are enabled automatically by --enable-dbgutil if Clang headers are found or explicitly using --enable-compiler-plugins.

Functionality

There are two kinds of plugin actions:

  • compile checks - these are run during normal compilation
  • rewriters - these must be run manually and modify source files

Each source has a comment saying whether it's compile check or a rewriter and description of functionality.

Compile Checks

Used during normal compilation to perform additional checks. All warnings and errors are marked '[loplugin]' in the message.

Rewriters

Rewriters analyse and possibly modify given source files. Usage: make COMPILER_PLUGIN_TOOL=<rewriter_name> Additional optional make arguments:

  • it is possible to also pass FORCE_COMPILE=all to make to trigger rebuild of all source files, even those that are up to date. FORCE_COMPILE takes a list of gbuild targets specifying where to run the rewriter ('all' means everything, '-' prepended means to not enable, '/' appended means everything in the directory; there is no ordering, more specific overrides more general, and disabling takes precedence). Example: FORCE_COMPILE="all -sw/ -Library_sc"

  • UPDATE_FILES=<scope> - limits which modified files will be actually written back with the changes

    • mainfile - only the main .cxx file will be modified (default)
    • all - all source files involved will be modified (possibly even header files from other LO modules), 3rd party header files are however never modified
    • <module> - only files in the given LO module (toplevel directory) will be modified (including headers)

Modifications will be written directly to the source files.

Some rewriter plugins are dual-mode and can also be used in a non-rewriting mode in which they emit warnings for problematic code that they would otherwise automatically rewrite. When any rewriter is enabled explicitly via make COMPILER_PLUGIN_TOOL=<rewriter_name> it works in rewriting mode (and all other plugins are disabled), but when no rewriter is explicitly enabled (i.e., just make), all dual-mode rewriters are enabled in non-rewriting mode (along with all non-rewriter plugins; and all non--dual-mode plugins are disabled). The typical process to use such a dual-mode rewriter X in rewriting mode is

make COMPILER_PLUGIN_WARNINGS_ONLY=X \
&& make COMPILER_PLUGIN_TOOL=X FORCE_COMPILE=all UPDATE_FILES=all

which first generates a full build without failing due to warnings from plugin X in non-rewriting mode (in case of --enable-werror) and then repeats the build in rewriting mode (during which no object files are generate).

Code Documentation / HowTos

https://wiki.documentfoundation.org/Clang_plugins