13 Commits
Author SHA1 Message Date
Michael Weghorn dec8cca513 Revert "Ignore loplugin:pointerbool/implicitboolconversion ...
... for some soltools C programs"

The issues previously seen with current glibc versions are
now addressed differently by

    Change-Id: I53d66f280ea82d295a2c2c086f4d02a965a893d7
    Author: Stephan Bergmann <stephan.bergmann@collabora.com>
    Date:   Wed Sep 16 13:08:28 2026 +0200

        Adapt loplugins to glibc 2.44 assert macro internals

, so revert the previous workaround again.

This reverts commit 5d72f86b56.

Change-Id: Ide517b9592ee1dbf444f000f48b901d474352c07
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211064
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2026-09-21 11:51:57 +02:00
Stephan Bergmann e53d782042 Adapt loplugins to glibc 2.44 assert macro internals
...which started to cause issues like

> [CXX] sal/osl/all/acceptableaccessdenial.cxx
> engine/sal/osl/all/acceptableaccessdenial.cxx:30:5: error: implicit conversion (IntegralCast) from 'bool' to 'int' [loplugin:implicitboolconversion]
>    30 |     assert(acceptableAccessDenials > 0);
>       |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /usr/include/assert.h:139:23: note: expanded from macro 'assert'
>   139 |       ? void (1 ? 1 : bool (__VA_ARGS__))                               \
>       |                       ^~~~~~~~~~~~~~~~~~
> engine/sal/osl/all/acceptableaccessdenial.cxx:30:5: error: redundant functional cast from 'bool' to 'bool' [loplugin:redundantcast]
>    30 |     assert(acceptableAccessDenials > 0);
>       |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /usr/include/assert.h:139:23: note: expanded from macro 'assert'
>   139 |       ? void (1 ? 1 : bool (__VA_ARGS__))                               \
>       |                       ^~~~~~~~~~~~~~~~~~

and

> [C  ] soltools/cpp/_tokens.c
> engine/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:164:42: note: expanded from macro 'assert'
>   164 |     ((void) sizeof (__assert_single_arg (__VA_ARGS__)), __extension__ ({ \
>       |                                          ^~~~~~~~~~~
> /usr/include/assert.h:114:40: note: method here [loplugin:pointerbool]
>   114 | extern _Bool __assert_single_arg (_Bool);
>       |                                   ~~~~~^
> engine/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:164:42: note: expanded from macro 'assert'
>   164 |     ((void) sizeof (__assert_single_arg (__VA_ARGS__)), __extension__ ({ \
>       |                                          ^~~~~~~~~~~

and

> [CPT] compilerplugins/clang/test/consttobool.cxx
> error: 'expected-error' diagnostics seen but not expected:
>   Line 72: implicit conversion of constant &"msg"[0] of type 'const char *' to 'bool'; use 'true' instead [loplugin:consttobool]
> 1 error generated.

against glibc-devel-2.44-1.fc45.x86_64

[Cherry-pick note by Michael Weghorn:
clang-format was run on the files modified by this commit
to adhere to code style as mandated by the LibreOffice clang-format rules,
while the Collabora repository that this commit was cherry-picked
from doesn't check clang-format rules any more.
Based on the discussion in
https://gerrit.libreoffice.org/c/core/+/211063/comments/d368cf20_d66d1a50 ,
I'm adding myself as co-author to clarify the cherry-picked commit
contains those additional changes to the original commit by Stephan
from the Collabora main branch.]

Signed-off-by: Stephan Bergmann <stephan.bergmann@collabora.com>
Change-Id: I53d66f280ea82d295a2c2c086f4d02a965a893d7
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/12738
Reviewed-by: Noel Grandin <noel.grandin@collabora.com>
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
(cherry picked from commit ecce89b1fe7f0b1f09c13c46625b33443b1dadfb)
Co-authored-by: Michael Weghorn <m.weghorn@posteo.de>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211063
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2026-09-21 11:49:48 +02:00
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
Stephan Bergmann 3289b1609e Adapt compilerplugins to Clang baseline bump
...as of e8fd52037a "Update README.md after Clang
bump to 18"

Change-Id: I2512205aa22ade1da17c414066a4f9e3d82bc99e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195099
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
2025-12-07 16:46:58 +01:00
Stephan Bergmann 6f33d21fdd Adapt compilerplugins to Clang 17 trunk "Remove llvm::Optional"
(<https://github.com/llvm/llvm-project/commit/397f2e9ebee8d8e45547e90dd05228d7f965df67>)

Change-Id: I51acda5951f8250d1a1b47e1c2612199ae7338a2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152618
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-06-05 19:46:50 +02:00
Stephan Bergmann fb992aefc8 Adapt to changes in llvm::Optional
<https://github.com/llvm/llvm-project/commit/3c49576417bab1b07764aa0b22664cbc8d3c3f53>
"[ADT] Add has_value, value, value_or to llvm::Optional" is in Clang 15, and
<https://github.com/llvm/llvm-project/commit/b5f8d42efe3e246d582d4a1a328fac915e4ce8dc>
"[ADT] Deprecate Optional::{hasValue,getValue} (NFC)" is in Clang 16 trunk,
causing

> In file included from compilerplugins/clang/sharedvisitor/sharedvisitor.cxx:95:
> compilerplugins/clang/pointerbool.cxx:118:21: error: 'hasValue' is deprecated: Use has_value instead. [-Werror,-Wdeprecated-declarations]
>             if (ret.hasValue() && (ret.getValue() == 1 || ret.getValue() == 0))
>                     ^
> ~/llvm/inst/include/llvm/ADT/Optional.h:324:5: note: 'hasValue' has been explicitly marked deprecated here
>   [[deprecated("Use has_value instead.")]] constexpr bool hasValue() const {
>     ^

etc.

Change-Id: I377effe29fc6752484d2870b9a0fd66fddc26bfc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137982
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-08-08 21:04:10 +02:00
Stephan Bergmann d1a2b80b9d Bump compiler plugins Clang baseline to 12.0.1
...as discussed in the mail thread starting at
<https://lists.freedesktop.org/archives/libreoffice/2020-November/086234.html>
"Bump --enable-compiler-plugins Clang baseline?" (and now picked up again at
<https://lists.freedesktop.org/archives/libreoffice/2022-February/088459.html>
"Re: Bump --enable-compiler-plugins Clang baseline?"), and clean up
compilerplugins/clang/ accordingly

Change-Id: I5e81c6fdcc363aeefd6227606225b526fdf7ac16
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129989
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-02-17 21:45:06 +01:00
Noel 6907cbb897 improve loplugin:pointerbool
to look through template instantiations involving std::forward

motivated by
    commit b1617acde1
    drop RadioButton arg defaults
    the nBits arg in builder.cxx was in the wrong place

Change-Id: I222ea2aeea6f44ae54839e824a247a8105392c2d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109789
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-01-22 17:46:01 +01:00
Noel Grandin 40fc30d05d convert some plugins to LO_CLANG_SHARED_PLUGINS
Change-Id: I63c9e010d83c24e18a36164ceb0441e48b757142
Reviewed-on: https://gerrit.libreoffice.org/75725
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-07-16 21:31:22 +02:00
Noel Grandin 75dd5d2e73 add EvaluateAsInt compat function for latest clang
the old EvaluateAsInt method has been dropped as from current clang

Change-Id: Ie30d1547ad8de777badff4b380d2fc9fb261e8fe
Reviewed-on: https://gerrit.libreoffice.org/64107
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-11-27 17:16:05 +01:00
Noel Grandin 1fd27a7931 filter out AST in more plugins
I seem to have missed quite a few in

    commit 9f4d23c151
    filter out some of the AST in the plugins

This nets me another 14% improvement

Change-Id: I39b980b49ced560f768045dbedd3ddfef29306c1
Reviewed-on: https://gerrit.libreoffice.org/59501
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-08-23 16:34:48 +02:00
Noel Grandin 5d15bb5849 remove debugging code
Change-Id: Ia5018354a764f900091cb5e03327721fa66591c9
2018-02-06 09:48:06 +02:00
Noel Grandin 91b4e45316 new loplugin: pointerbool
look for possibly bogus implicit conversions to bool when passing
(normally pointer) args to bool params.

this plugin comes in the wake of a couple of bugs caused by refactoring,
where some of the call sites were not currently updated.

Of the changes, the following are real bugs:

desktop/../dp_persmap.cxx

StartInputFieldDlg
    in sw/../fldmgr.cxx
which occurred as a result of
    commit 39d719a80d
    Date:   Tue May 3 11:39:37 2016 +0200
    tdf#99529 sw: don't pop up input field dialog before inserting field

CSerializationURLEncoded::encode_and_append in
    forms/../serialization_urlencoded.cxx

XclExpCFImpl::XclExpCFImpl
    in sc/../xecontent.cxx
I have no idea how to properly fix this, just made a guess.

SwDocTest::test64kPageDescs
    in sw/qa/core/uwriter.cxx
which looks like a simple copy/paste error.

Change-Id: I795ebd5ef485a1d36863dc27fe13832989f5a441
Reviewed-on: https://gerrit.libreoffice.org/48291
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-01-23 10:41:38 +01:00