compilerplugins/clang/compat.hxx              |   11 +++++++++++
 compilerplugins/clang/external.cxx            |    3 ++-
 compilerplugins/clang/externandnotdefined.cxx |    3 ++-
 compilerplugins/clang/plugin.cxx              |    2 +-
 compilerplugins/clang/redundantinline.cxx     |    3 ++-
 compilerplugins/clang/unreffun.cxx            |    3 ++-
 6 files changed, 20 insertions(+), 5 deletions(-)

New commits:
commit 5323c18753504ae99e271f98052b13271343de6f
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Fri Nov 3 22:42:51 2023 +0100
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Sat Nov 4 09:51:18 2023 +0100

    Adapt to Clang 18 trunk Linkage rework
    
    
<https://github.com/llvm/llvm-project/commit/8775947633bf189e1847707932b1015f04640ea0>
    "[clang][NFC] Refactor clang::Linkage"
    
    Change-Id: I35e3a3c7e3de29e4f3b9ee8dfc34e39ba2aa1c70
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158919
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx
index 21a3c4ae4018..df4052ef108a 100644
--- a/compilerplugins/clang/compat.hxx
+++ b/compilerplugins/clang/compat.hxx
@@ -91,6 +91,17 @@ constexpr clang::ElaboratedTypeKeyword None = 
clang::ETK_None;
 #endif
 }
 
+namespace Linkage
+{
+#if CLANG_VERSION >= 180000
+constexpr clang::Linkage External = clang::Linkage::External;
+constexpr clang::Linkage Module = clang::Linkage::Module;
+#else
+constexpr clang::Linkage External = clang::ExternalLinkage;
+constexpr clang::Linkage Module = clang::ModuleLinkage;
+#endif
+}
+
 inline bool EvaluateAsInt(clang::Expr const * expr, llvm::APSInt& intRes, 
const clang::ASTContext& ctx) {
     clang::Expr::EvalResult res;
     bool b = expr->EvaluateAsInt(res, ctx);
diff --git a/compilerplugins/clang/external.cxx 
b/compilerplugins/clang/external.cxx
index de2b51ff82bc..8c8733553907 100644
--- a/compilerplugins/clang/external.cxx
+++ b/compilerplugins/clang/external.cxx
@@ -17,6 +17,7 @@
 #include "clang/Sema/SemaDiagnostic.h"
 
 #include "check.hxx"
+#include "compat.hxx"
 #include "plugin.hxx"
 
 namespace
@@ -468,7 +469,7 @@ private:
         {
             return true;
         }
-        if (decl->getLinkageInternal() < ModuleLinkage)
+        if (decl->getLinkageInternal() < compat::Linkage::Module)
         {
             return true;
         }
diff --git a/compilerplugins/clang/externandnotdefined.cxx 
b/compilerplugins/clang/externandnotdefined.cxx
index 5fd59ca4b58c..5d8803a6faaa 100644
--- a/compilerplugins/clang/externandnotdefined.cxx
+++ b/compilerplugins/clang/externandnotdefined.cxx
@@ -11,6 +11,7 @@
 
 #include <string>
 
+#include "compat.hxx"
 #include "plugin.hxx"
 
 // Having an extern prototype for a method in a module and not actually 
declaring that method is dodgy.
@@ -35,7 +36,7 @@ bool ExternAndNotDefined::VisitFunctionDecl(const 
FunctionDecl * functionDecl) {
     }
     if (functionDecl->isDefined() || functionDecl->isPure()
       || (functionDecl->getLinkageAndVisibility().getLinkage()
-          != ExternalLinkage)) {
+          != compat::Linkage::External)) {
         return true;
     }
     //TODO, filtering out anything template for now:
diff --git a/compilerplugins/clang/plugin.cxx b/compilerplugins/clang/plugin.cxx
index e2d4d7fbf0a4..10102d426079 100644
--- a/compilerplugins/clang/plugin.cxx
+++ b/compilerplugins/clang/plugin.cxx
@@ -1013,7 +1013,7 @@ int derivedFromCount(QualType subclassQt, QualType 
baseclassQt)
 // a variable declared in an 'extern "..." {...}'-style linkage-specification 
as
 // if it contained the 'extern' specifier:
 bool hasExternalLinkage(VarDecl const * decl) {
-    if (decl->getLinkageAndVisibility().getLinkage() != ExternalLinkage) {
+    if (decl->getLinkageAndVisibility().getLinkage() != 
compat::Linkage::External) {
         return false;
     }
     for (auto ctx = decl->getLexicalDeclContext();
diff --git a/compilerplugins/clang/redundantinline.cxx 
b/compilerplugins/clang/redundantinline.cxx
index 1172dfec33d3..962a11ed6037 100644
--- a/compilerplugins/clang/redundantinline.cxx
+++ b/compilerplugins/clang/redundantinline.cxx
@@ -10,6 +10,7 @@
 
 #include <cassert>
 
+#include "compat.hxx"
 #include "plugin.hxx"
 
 namespace {
@@ -141,7 +142,7 @@ private:
     }
 
     bool handleNonExternalLinkage(FunctionDecl const * decl) {
-        if (decl->getLinkageInternal() >= ModuleLinkage) {
+        if (decl->getLinkageInternal() >= compat::Linkage::Module) {
             return false;
         }
         if (!compiler.getSourceManager().isInMainFile(decl->getLocation())) {
diff --git a/compilerplugins/clang/unreffun.cxx 
b/compilerplugins/clang/unreffun.cxx
index 353eee5f0b31..fcb6f04016b7 100644
--- a/compilerplugins/clang/unreffun.cxx
+++ b/compilerplugins/clang/unreffun.cxx
@@ -16,6 +16,7 @@
 #include "clang/AST/Attr.h"
 #include "clang/Sema/SemaInternal.h" // warn_unused_function
 
+#include "compat.hxx"
 #include "plugin.hxx"
 
 namespace {
@@ -152,7 +153,7 @@ bool UnrefFun::VisitFunctionDecl(FunctionDecl const * decl) 
{
         return true;
     }
     LinkageInfo info(canon->getLinkageAndVisibility());
-    if (info.getLinkage() == ExternalLinkage
+    if (info.getLinkage() == compat::Linkage::External
         && loplugin::hasCLanguageLinkageType(canon) && canon->isDefined()
         && ((decl == canon && info.getVisibility() == DefaultVisibility)
             || ((canon->hasAttr<ConstructorAttr>()

Reply via email to