compilerplugins/clang/compat.hxx | 9 +++++++++ compilerplugins/clang/dynexcspec.cxx | 2 +- compilerplugins/clang/externandnotdefined.cxx | 2 +- compilerplugins/clang/fakebool.cxx | 4 ++-- compilerplugins/clang/pluginhandler.cxx | 2 +- compilerplugins/clang/salcall.cxx | 2 +- compilerplugins/clang/unnecessaryvirtual.cxx | 4 +++- compilerplugins/clang/unoaggregation.cxx | 3 ++- 8 files changed, 20 insertions(+), 8 deletions(-)
New commits: commit bd10851e9e5b4ecc5624f1fee8331e52c96df606 Author: Stephan Bergmann <stephan.bergm...@allotropia.de> AuthorDate: Sun Jan 21 16:34:05 2024 +0100 Commit: Stephan Bergmann <stephan.bergm...@allotropia.de> CommitDate: Sun Jan 21 19:41:28 2024 +0100 Adapt compilerplugins to Clang 18 trunk isPure -> isPureVirtual rename ...<https://github.com/llvm/llvm-project/commit/e90e43fb9cd1d305f7196cd526aa503374e0f616> "[Clang][NFC] Rename CXXMethodDecl::isPure -> is VirtualPure" Change-Id: I27b7cd40c84c71804bef396d0bff4ee2683cb3af Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162345 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de> diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx index 42ab1a80545c..cc3192ea9204 100644 --- a/compilerplugins/clang/compat.hxx +++ b/compilerplugins/clang/compat.hxx @@ -12,6 +12,7 @@ #include <string> #include <utility> +#include "clang/AST/Decl.h" #include "clang/AST/Expr.h" #include "clang/AST/ExprCXX.h" #include "clang/Basic/SourceManager.h" @@ -241,6 +242,14 @@ inline bool isOrdinary(clang::StringLiteral const * expr) { #endif } +inline bool isPureVirtual(clang::FunctionDecl const * decl) { +#if CLANG_VERSION >= 180000 + return decl->isPureVirtual(); +#else + return decl->isPure(); +#endif +} + inline clang::TemplateTypeParmDecl const * getReplacedParameter( clang::SubstTemplateTypeParmType const * type) { diff --git a/compilerplugins/clang/dynexcspec.cxx b/compilerplugins/clang/dynexcspec.cxx index 2cedb8e046f2..483230e8cf31 100644 --- a/compilerplugins/clang/dynexcspec.cxx +++ b/compilerplugins/clang/dynexcspec.cxx @@ -80,7 +80,7 @@ public: << decl->getSourceRange(); } if (rewriter != nullptr) { - if (!(decl->isDefined() || decl->isPure())) { + if (!(decl->isDefined() || compat::isPureVirtual(decl))) { return true; } if (auto m = dyn_cast<CXXMethodDecl>(decl)) { diff --git a/compilerplugins/clang/externandnotdefined.cxx b/compilerplugins/clang/externandnotdefined.cxx index 5d8803a6faaa..8b04670b99bb 100644 --- a/compilerplugins/clang/externandnotdefined.cxx +++ b/compilerplugins/clang/externandnotdefined.cxx @@ -34,7 +34,7 @@ bool ExternAndNotDefined::VisitFunctionDecl(const FunctionDecl * functionDecl) { if (ignoreLocation(functionDecl)) { return true; } - if (functionDecl->isDefined() || functionDecl->isPure() + if (functionDecl->isDefined() || compat::isPureVirtual(functionDecl) || (functionDecl->getLinkageAndVisibility().getLinkage() != compat::Linkage::External)) { return true; diff --git a/compilerplugins/clang/fakebool.cxx b/compilerplugins/clang/fakebool.cxx index 23dac488cb14..274b9ef3d729 100644 --- a/compilerplugins/clang/fakebool.cxx +++ b/compilerplugins/clang/fakebool.cxx @@ -374,7 +374,7 @@ void FakeBool::run() { dyn_cast<FunctionDecl>( decl->getDeclContext()) ->getNameInfo().getLoc())) - || f->isDefined() || f->isPure()) + || f->isDefined() || compat::isPureVirtual(f)) && k != OverrideKind::MAYBE && rewrite(loc, fbk))) { report( @@ -425,7 +425,7 @@ void FakeBool::run() { if (!((compiler.getSourceManager().isInMainFile( compiler.getSourceManager().getSpellingLoc( decl->getNameInfo().getLoc())) - || f->isDefined() || f->isPure()) + || f->isDefined() || compat::isPureVirtual(f)) && rewrite(loc, fbk))) { report( diff --git a/compilerplugins/clang/pluginhandler.cxx b/compilerplugins/clang/pluginhandler.cxx index 6f4bab5a5349..0fb62eb56c48 100644 --- a/compilerplugins/clang/pluginhandler.cxx +++ b/compilerplugins/clang/pluginhandler.cxx @@ -430,7 +430,7 @@ static bool MethodsAndNestedClassesComplete(const CXXRecordDecl *RD, I != E && Complete; ++I) { if (const CXXMethodDecl *M = dyn_cast<CXXMethodDecl>(*I)) Complete = M->isDefined() || M->isDefaulted() || - (M->isPure() && !isa<CXXDestructorDecl>(M)); + (compat::isPureVirtual(M) && !isa<CXXDestructorDecl>(M)); else if (const FunctionTemplateDecl *F = dyn_cast<FunctionTemplateDecl>(*I)) // If the template function is marked as late template parsed at this // point, it has not been instantiated and therefore we have not diff --git a/compilerplugins/clang/salcall.cxx b/compilerplugins/clang/salcall.cxx index 06ff72e27a00..c6b8da579c57 100644 --- a/compilerplugins/clang/salcall.cxx +++ b/compilerplugins/clang/salcall.cxx @@ -152,7 +152,7 @@ bool SalCall::VisitFunctionDecl(FunctionDecl const* decl) if (!bCanonicalDeclIsSalCall) return true; - if (!decl->isThisDeclarationADefinition() && !(methodDecl && methodDecl->isPure())) + if (!decl->isThisDeclarationADefinition() && !(methodDecl && compat::isPureVirtual(methodDecl))) return true; m_decls.insert(decl); diff --git a/compilerplugins/clang/unnecessaryvirtual.cxx b/compilerplugins/clang/unnecessaryvirtual.cxx index ab8b63bd6f6b..b376f97c9b07 100644 --- a/compilerplugins/clang/unnecessaryvirtual.cxx +++ b/compilerplugins/clang/unnecessaryvirtual.cxx @@ -13,6 +13,7 @@ #include <set> #include <unordered_set> #include "config_clang.h" +#include "compat.hxx" #include "plugin.hxx" #include <fstream> @@ -166,7 +167,8 @@ bool UnnecessaryVirtual::VisitCXXMethodDecl( const CXXMethodDecl* methodDecl ) { const CXXMethodDecl *overriddenMethod = *iter; // we only care about the first level override to establish that a virtual qualifier was useful. - if (overriddenMethod->isPure() || overriddenMethod->size_overridden_methods() == 0) + if (compat::isPureVirtual(overriddenMethod) + || overriddenMethod->size_overridden_methods() == 0) { std::string aOverriddenNiceName = niceName(overriddenMethod); overridingSet.insert(aOverriddenNiceName); diff --git a/compilerplugins/clang/unoaggregation.cxx b/compilerplugins/clang/unoaggregation.cxx index 6cad29cf0915..a3be33f395f7 100644 --- a/compilerplugins/clang/unoaggregation.cxx +++ b/compilerplugins/clang/unoaggregation.cxx @@ -18,6 +18,7 @@ #include <cassert> #include "check.hxx" +#include "compat.hxx" #include "plugin.hxx" namespace @@ -85,7 +86,7 @@ bool basesHaveOnlyPureQueryInterface(CXXRecordDecl const* decl) { continue; } - if (!d2->isPure()) + if (!compat::isPureVirtual(d2)) { return false; }