compilerplugins/clang/compat.hxx | 9 +++++++++ compilerplugins/clang/implicitboolconversion.cxx | 2 +- compilerplugins/clang/loopvartoosmall.cxx | 4 ++-- 3 files changed, 12 insertions(+), 3 deletions(-)
New commits: commit d59aa7ddfdcb9a37655ce60cffd4187ce509102c Author: Stephan Bergmann <stephan.bergm...@allotropia.de> AuthorDate: Sun Jan 12 21:44:24 2025 +0100 Commit: Stephan Bergmann <stephan.bergm...@allotropia.de> CommitDate: Mon Jan 13 08:13:44 2025 +0100 Adapt compilerplugins to recent LLVM 20 trunk change <github.com/llvm/llvm-project/commit/cfe26358e3051755961fb1f3b46328dc2c326895> "Reapply '[clang] Avoid re-evaluating field bitwidth'" Change-Id: Ic31d5cd8251d0f83e7589e2f00e3c34789c75bad Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180150 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de> diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx index 829eb083a8e0..6ce5dccfe309 100644 --- a/compilerplugins/clang/compat.hxx +++ b/compilerplugins/clang/compat.hxx @@ -269,6 +269,15 @@ inline bool isUnnamedBitField(clang::FieldDecl const * decl) { #endif } +inline unsigned getBitWidthValue(clang::FieldDecl const * decl, clang::ASTContext const & context) { +#if CLANG_VERSION >= 200000 + (void) context; + return decl->getBitWidthValue(); +#else + return decl->getBitWidthValue(context); +#endif +} + inline clang::TemplateTypeParmDecl const * getReplacedParameter( clang::SubstTemplateTypeParmType const * type) { diff --git a/compilerplugins/clang/implicitboolconversion.cxx b/compilerplugins/clang/implicitboolconversion.cxx index 64bc97ff4999..5b0646a5e701 100644 --- a/compilerplugins/clang/implicitboolconversion.cxx +++ b/compilerplugins/clang/implicitboolconversion.cxx @@ -558,7 +558,7 @@ bool ImplicitBoolConversion::TraverseBinaryOperator(BinaryOperator * expr) { if (me != nullptr) { FieldDecl const * fd = dyn_cast<FieldDecl>(me->getMemberDecl()); if (fd != nullptr && fd->isBitField() - && fd->getBitWidthValue(compiler.getASTContext()) == 1) + && compat::getBitWidthValue(fd, compiler.getASTContext()) == 1) { auto const check = loplugin::TypeCheck(fd->getType()); bExt = check.Typedef("guint").GlobalNamespace() diff --git a/compilerplugins/clang/loopvartoosmall.cxx b/compilerplugins/clang/loopvartoosmall.cxx index bc03e94ca09b..33f4fbf4adc2 100644 --- a/compilerplugins/clang/loopvartoosmall.cxx +++ b/compilerplugins/clang/loopvartoosmall.cxx @@ -143,7 +143,7 @@ void LoopVarTooSmall::checkSubExpr(Expr const * expr, bool positive) { if (fd->isBitField()) { qt1BitWidth = std::max( qt1BitWidth, - fd->getBitWidthValue(compiler.getASTContext())); + compat::getBitWidthValue(fd, compiler.getASTContext())); } } else { return; @@ -184,7 +184,7 @@ void LoopVarTooSmall::checkSubExpr(Expr const * expr, bool positive) { if (fd->isBitField()) { qt2BitWidth = std::max( qt2BitWidth, - fd->getBitWidthValue(compiler.getASTContext())); + compat::getBitWidthValue(fd, compiler.getASTContext())); } } }