| 1 |
diff --git a/clang_delta/CommonRenameClassRewriteVisitor.h b/clang_delta/CommonRenameClassRewriteVisitor.h |
| 2 |
index 371bebbe..94b3f6fb 100644 |
| 3 |
--- a/clang_delta/CommonRenameClassRewriteVisitor.h |
| 4 |
+++ b/clang_delta/CommonRenameClassRewriteVisitor.h |
| 5 |
@@ -310,7 +310,11 @@ template<typename T> bool CommonRenameClassRewriteVisitor<T>:: |
| 6 |
dyn_cast<DependentTemplateSpecializationType>(Ty); |
| 7 |
TransAssert(DTST && "Bad DependentTemplateSpecializationType!"); |
| 8 |
|
| 9 |
+#if LLVM_VERSION_MAJOR >= 21 |
| 10 |
+ const IdentifierInfo *IdInfo = DTST->getDependentTemplateName().getName().getIdentifier(); |
| 11 |
+#else |
| 12 |
const IdentifierInfo *IdInfo = DTST->getIdentifier(); |
| 13 |
+#endif |
| 14 |
std::string IdName = IdInfo->getName().str(); |
| 15 |
std::string Name; |
| 16 |
if (getNewNameByName(IdName, Name)) { |
| 17 |
diff --git a/clang_delta/RemoveNamespace.cpp b/clang_delta/RemoveNamespace.cpp |
| 18 |
index 0f8fc427..1d680b64 100644 |
| 19 |
--- a/clang_delta/RemoveNamespace.cpp |
| 20 |
+++ b/clang_delta/RemoveNamespace.cpp |
| 21 |
@@ -440,7 +440,11 @@ bool RemoveNamespaceRewriteVisitor::VisitDependentTemplateSpecializationTypeLoc( |
| 22 |
dyn_cast<DependentTemplateSpecializationType>(Ty); |
| 23 |
TransAssert(DTST && "Bad DependentTemplateSpecializationType!"); |
| 24 |
|
| 25 |
+#if LLVM_VERSION_MAJOR >= 21 |
| 26 |
+ const IdentifierInfo *IdInfo = DTST->getDependentTemplateName().getName().getIdentifier(); |
| 27 |
+#else |
| 28 |
const IdentifierInfo *IdInfo = DTST->getIdentifier(); |
| 29 |
+#endif |
| 30 |
std::string IdName = IdInfo->getName().str(); |
| 31 |
std::string Name; |
| 32 |
|
| 33 |
@@ -562,8 +566,10 @@ bool RemoveNamespaceRewriteVisitor::TraverseNestedNameSpecifierLoc( |
| 34 |
ND = NAD->getNamespace()->getCanonicalDecl(); |
| 35 |
break; |
| 36 |
} |
| 37 |
- case NestedNameSpecifier::TypeSpec: // Fall-through |
| 38 |
- case NestedNameSpecifier::TypeSpecWithTemplate: |
| 39 |
+#if LLVM_VERSION_MAJOR < 21 |
| 40 |
+ case NestedNameSpecifier::TypeSpecWithTemplate: // Fall-through |
| 41 |
+#endif |
| 42 |
+ case NestedNameSpecifier::TypeSpec: |
| 43 |
TraverseTypeLoc(Loc.getTypeLoc()); |
| 44 |
break; |
| 45 |
default: |
| 46 |
diff --git a/clang_delta/RemoveUnusedFunction.cpp b/clang_delta/RemoveUnusedFunction.cpp |
| 47 |
index f0632be5..225942ed 100644 |
| 48 |
--- a/clang_delta/RemoveUnusedFunction.cpp |
| 49 |
+++ b/clang_delta/RemoveUnusedFunction.cpp |
| 50 |
@@ -254,7 +254,11 @@ bool RUFAnalysisVisitor::VisitFunctionDecl(FunctionDecl *FD) |
| 51 |
|
| 52 |
if (FD->isReferenced() || |
| 53 |
FD->isMain() || |
| 54 |
+#if LLVM_VERSION_MAJOR >= 21 |
| 55 |
+ FD->hasAttr<DeviceKernelAttr>() || |
| 56 |
+#else |
| 57 |
FD->hasAttr<OpenCLKernelAttr>() || |
| 58 |
+#endif |
| 59 |
ConsumerInstance->hasReferencedSpecialization(CanonicalFD) || |
| 60 |
ConsumerInstance->isInlinedSystemFunction(CanonicalFD) || |
| 61 |
ConsumerInstance->isInReferencedSet(CanonicalFD) || |
| 62 |
diff --git a/clang_delta/RenameFun.cpp b/clang_delta/RenameFun.cpp |
| 63 |
index 8dee2431..f7c2255e 100644 |
| 64 |
--- a/clang_delta/RenameFun.cpp |
| 65 |
+++ b/clang_delta/RenameFun.cpp |
| 66 |
@@ -261,7 +261,11 @@ void RenameFun::addFun(const FunctionDecl *FD) |
| 67 |
{ |
| 68 |
std::string Name = FD->getNameAsString(); |
| 69 |
// Skip special functions |
| 70 |
+#if LLVM_VERSION_MAJOR >= 21 |
| 71 |
+ if (isSpecialFun(Name) || FD->hasAttr<DeviceKernelAttr>()) |
| 72 |
+#else |
| 73 |
if (isSpecialFun(Name) || FD->hasAttr<OpenCLKernelAttr>()) |
| 74 |
+#endif |
| 75 |
FunToNameMap[FD] = Name; |
| 76 |
|
| 77 |
if (FunToNameMap.find(FD) != FunToNameMap.end()) |
| 78 |
diff --git a/clang_delta/Transformation.cpp b/clang_delta/Transformation.cpp |
| 79 |
index b350eec5..24765971 100644 |
| 80 |
--- a/clang_delta/Transformation.cpp |
| 81 |
+++ b/clang_delta/Transformation.cpp |
| 82 |
@@ -635,8 +635,10 @@ const DeclContext *Transformation::getDeclContextFromSpecifier( |
| 83 |
const NamespaceAliasDecl *NAD = NNS->getAsNamespaceAlias(); |
| 84 |
return NAD->getNamespace()->getCanonicalDecl(); |
| 85 |
} |
| 86 |
- case NestedNameSpecifier::TypeSpec: // Fall-through |
| 87 |
- case NestedNameSpecifier::TypeSpecWithTemplate: { |
| 88 |
+#if LLVM_VERSION_MAJOR < 21 |
| 89 |
+ case NestedNameSpecifier::TypeSpecWithTemplate: // Fall-through |
| 90 |
+#endif |
| 91 |
+ case NestedNameSpecifier::TypeSpec: { |
| 92 |
const Type *Ty = NNS->getAsType(); |
| 93 |
if (const RecordType *RT = Ty->getAs<RecordType>()) |
| 94 |
return RT->getDecl(); |
| 95 |
diff --git a/clang_delta/TransformationManager.cpp b/clang_delta/TransformationManager.cpp |
| 96 |
index 79b17cee..700c42c5 100644 |
| 97 |
--- a/clang_delta/TransformationManager.cpp |
| 98 |
+++ b/clang_delta/TransformationManager.cpp |
| 99 |
@@ -125,7 +125,7 @@ bool TransformationManager::initializeCompilerInstance(std::string &ErrorMsg) |
| 100 |
ClangInstance->createFileManager(); |
| 101 |
|
| 102 |
if(CLCPath != NULL && ClangInstance->hasFileManager() && |
| 103 |
- ClangInstance->getFileManager().getDirectory(CLCPath, false)) { |
| 104 |
+ ClangInstance->getFileManager().getOptionalDirectoryRef(CLCPath, false)) { |
| 105 |
Args.push_back("-I"); |
| 106 |
Args.push_back(CLCPath); |
| 107 |
} |
| 108 |
@@ -146,8 +146,13 @@ bool TransformationManager::initializeCompilerInstance(std::string &ErrorMsg) |
| 109 |
} |
| 110 |
|
| 111 |
TargetInfo *Target = |
| 112 |
+#if LLVM_VERSION_MAJOR >= 21 |
| 113 |
+ TargetInfo::CreateTargetInfo(ClangInstance->getDiagnostics(), |
| 114 |
+ ClangInstance->getInvocation().getTargetOpts()); |
| 115 |
+#else |
| 116 |
TargetInfo::CreateTargetInfo(ClangInstance->getDiagnostics(), |
| 117 |
ClangInstance->getInvocation().TargetOpts); |
| 118 |
+#endif |
| 119 |
ClangInstance->setTarget(Target); |
| 120 |
|
| 121 |
if (const char *env = getenv("CREDUCE_INCLUDE_PATH")) { |