From 5d72f86b56891d0db0e74b820df54edf929fdfd2 Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Mon, 24 Aug 2026 15:04:32 +0200 Subject: [PATCH] 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 Tested-by: Jenkins --- compilerplugins/clang/implicitboolconversion.cxx | 10 +++++++++- compilerplugins/clang/pointerbool.cxx | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/compilerplugins/clang/implicitboolconversion.cxx b/compilerplugins/clang/implicitboolconversion.cxx index 2b39525bc9ba..4ef254746a96 100644 --- a/compilerplugins/clang/implicitboolconversion.cxx +++ b/compilerplugins/clang/implicitboolconversion.cxx @@ -241,7 +241,15 @@ public: FilteringPlugin(data) {} virtual void run() override - { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); } + { + std::string fn(handler.getMainFileName()); + loplugin::normalizeDotDotInFilePath(fn); + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/soltools/cpp") + || loplugin::hasPathnamePrefix(fn, SRCDIR "/soltools/mkdepend")) + return; + + TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); + } bool TraverseCallExpr(CallExpr * expr); diff --git a/compilerplugins/clang/pointerbool.cxx b/compilerplugins/clang/pointerbool.cxx index 6225286a3dff..f5c2dfd4951b 100644 --- a/compilerplugins/clang/pointerbool.cxx +++ b/compilerplugins/clang/pointerbool.cxx @@ -78,6 +78,12 @@ bool PointerBool::TraverseFunctionDecl(FunctionDecl* decl) bool PointerBool::VisitCallExpr(CallExpr const* callExpr) { + std::string fn(handler.getMainFileName()); + loplugin::normalizeDotDotInFilePath(fn); + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/soltools/cpp") + || loplugin::hasPathnamePrefix(fn, SRCDIR "/soltools/mkdepend")) + return true; + if (ignoreLocation(callExpr)) return true; // TODO this doesn't currently work, the args and the params don't seem to line up