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.bergmann@allotropia.de>
This commit is contained in:
Stephan Bergmann
2025-01-12 21:44:24 +01:00
parent 210f304108
commit d59aa7ddfd
3 changed files with 12 additions and 3 deletions

View File

@@ -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)
{

View File

@@ -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()

View File

@@ -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()));
}
}
}