Skip to content

Commit

Permalink
Support LLVM 18: changes in ElaboratedTypeKeyword
Browse files Browse the repository at this point in the history
  • Loading branch information
marxin committed Nov 5, 2023
1 parent edd7720 commit 07919b7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions clang_delta/ReplaceDependentName.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -155,8 +161,14 @@ void ReplaceDependentName::handleOneDependentNameTypeLoc(
const DependentNameType *DNT =
dyn_cast<DependentNameType>(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;
Expand Down
5 changes: 5 additions & 0 deletions clang_delta/ReplaceDependentTypedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ bool ReplaceDependentTypedef::isValidType(const QualType &QT)
case Type::Elaborated: {
const ElaboratedType *ETy = dyn_cast<ElaboratedType>(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:
Expand Down

0 comments on commit 07919b7

Please sign in to comment.