From 07919b7fc916ad8acae71faf5b9397d0cfaf4666 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Sun, 5 Nov 2023 08:24:07 +0100 Subject: [PATCH] Support LLVM 18: changes in ElaboratedTypeKeyword --- clang_delta/ReplaceDependentName.cpp | 12 ++++++++++++ clang_delta/ReplaceDependentTypedef.cpp | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/clang_delta/ReplaceDependentName.cpp b/clang_delta/ReplaceDependentName.cpp index 00ba851f..27a13ed6 100644 --- a/clang_delta/ReplaceDependentName.cpp +++ b/clang_delta/ReplaceDependentName.cpp @@ -120,8 +120,14 @@ void ReplaceDependentName::handleOneElaboratedTypeLoc( return; const ElaboratedType *ET = TLoc.getTypePtr(); + +#if LLVM_VERSION_MAJOR >= 18 + if ((ET->getKeyword() != ElaboratedTypeKeyword::Typename) && (ET->getKeyword() != ElaboratedTypeKeyword::None)) + return; +#else if ((ET->getKeyword() != ETK_Typename) && (ET->getKeyword() != ETK_None)) return; +#endif if (TLoc.getQualifierLoc().getBeginLoc().isInvalid()) return; @@ -155,8 +161,14 @@ void ReplaceDependentName::handleOneDependentNameTypeLoc( const DependentNameType *DNT = dyn_cast(TLoc.getTypePtr()); TransAssert(DNT && "NULL DependentNameType!"); + +#if LLVM_VERSION_MAJOR >= 18 + if (DNT->getKeyword() != ElaboratedTypeKeyword::Typename) + return; +#else if (DNT->getKeyword() != ETK_Typename) return; +#endif std::string Str = ""; bool Typename = false; diff --git a/clang_delta/ReplaceDependentTypedef.cpp b/clang_delta/ReplaceDependentTypedef.cpp index f0f5c373..6790656c 100644 --- a/clang_delta/ReplaceDependentTypedef.cpp +++ b/clang_delta/ReplaceDependentTypedef.cpp @@ -114,7 +114,12 @@ bool ReplaceDependentTypedef::isValidType(const QualType &QT) case Type::Elaborated: { const ElaboratedType *ETy = dyn_cast(Ty); ElaboratedTypeKeyword Keyword = ETy->getKeyword(); + +#if LLVM_VERSION_MAJOR >= 18 + return ((Keyword == ElaboratedTypeKeyword::Typename) || (Keyword == ElaboratedTypeKeyword::None)); +#else return ((Keyword == ETK_Typename) || (Keyword == ETK_None)); +#endif } default: