| 1 |
--- a/clang_delta/ExpressionDetector.cpp |
| 2 |
+++ b/clang_delta/ExpressionDetector.cpp |
| 3 |
@@ -62,9 +62,20 @@ public: |
| 4 |
virtual void InclusionDirective(SourceLocation HashLoc, |
| 5 |
const Token &IncludeTok, |
| 6 |
StringRef FileName, bool IsAngled, |
| 7 |
- CharSourceRange FilenameRange, OptionalFileEntryRef File, |
| 8 |
+ CharSourceRange FilenameRange, |
| 9 |
+#if LLVM_VERSION_MAJOR < 15 |
| 10 |
+ const FileEntry *File, |
| 11 |
+#elif LLVM_VERSION_MAJOR < 16 |
| 12 |
+ Optional<FileEntryRef> File, |
| 13 |
+#else |
| 14 |
+ OptionalFileEntryRef File, |
| 15 |
+#endif |
| 16 |
StringRef SearchPath, StringRef RelativePath, |
| 17 |
+#if LLVM_VERSION_MAJOR < 19 |
| 18 |
const Module *Imported, |
| 19 |
+#else |
| 20 |
+ const Module *SuggestedModule, bool ModuleImported, |
| 21 |
+#endif |
| 22 |
SrcMgr::CharacteristicKind FileType) override; |
| 23 |
|
| 24 |
private: |
| 25 |
@@ -80,12 +91,22 @@ private: |
| 26 |
void IncludesPPCallbacks::InclusionDirective(SourceLocation HashLoc, |
| 27 |
const Token &/*IncludeTok*/, |
| 28 |
StringRef FileName, |
| 29 |
- bool /*IsAngled*/, |
| 30 |
+ bool /*IsAngled*/, |
| 31 |
CharSourceRange /*FilenameRange*/, |
| 32 |
+#if LLVM_VERSION_MAJOR < 15 |
| 33 |
+ const FileEntry * /*File*/, |
| 34 |
+#elif LLVM_VERSION_MAJOR < 16 |
| 35 |
+ Optional<FileEntryRef> /*File*/, |
| 36 |
+#else |
| 37 |
OptionalFileEntryRef /*File*/, |
| 38 |
+#endif |
| 39 |
StringRef /*SearchPath*/, |
| 40 |
StringRef /*RelativePath*/, |
| 41 |
- const Module * /*Imported*/, |
| 42 |
+#if LLVM_VERSION_MAJOR < 19 |
| 43 |
+ const Module *Imported, |
| 44 |
+#else |
| 45 |
+ const Module *SuggestedModule, bool ModuleImported, |
| 46 |
+#endif |
| 47 |
SrcMgr::CharacteristicKind /*FileType*/) |
| 48 |
{ |
| 49 |
if (!SrcManager.isInMainFile(HashLoc)) |
| 50 |
@@ -118,7 +139,11 @@ bool LocalTmpVarCollector::VisitDeclRefE |
| 51 |
const VarDecl *VD = dyn_cast<VarDecl>(DRE->getDecl()); |
| 52 |
if (!VD) |
| 53 |
return true; |
| 54 |
+#if LLVM_VERSION_MAJOR < 18 |
| 55 |
if (VD->getName().startswith(Prefix)) |
| 56 |
+#else |
| 57 |
+ if (VD->getName().starts_with(Prefix)) |
| 58 |
+#endif |
| 59 |
TmpVars.push_back(VD); |
| 60 |
return true; |
| 61 |
} |
| 62 |
@@ -363,7 +388,11 @@ void ExpressionDetector::addOneTempVar(c |
| 63 |
{ |
| 64 |
if (!VD) |
| 65 |
return; |
| 66 |
+#if LLVM_VERSION_MAJOR < 18 |
| 67 |
if (!VD->getName().startswith(TmpVarNamePrefix)) |
| 68 |
+#else |
| 69 |
+ if (!VD->getName().starts_with(TmpVarNamePrefix)) |
| 70 |
+#endif |
| 71 |
return; |
| 72 |
if (const Expr *E = VD->getInit()) |
| 73 |
ProcessedExprs[VD] = E->IgnoreParenImpCasts(); |
| 74 |
@@ -374,9 +403,15 @@ bool ExpressionDetector::refToTmpVar(con |
| 75 |
StringRef Name = ND->getName(); |
| 76 |
// We don't want to repeatly replace temporary variables |
| 77 |
// __creduce_expr_tmp_xxx, __creduce_printed_yy and __creduce_checked_zzz. |
| 78 |
+#if LLVM_VERSION_MAJOR < 18 |
| 79 |
return Name.startswith(TmpVarNamePrefix) || |
| 80 |
Name.startswith(PrintedVarNamePrefix) || |
| 81 |
Name.startswith(CheckedVarNamePrefix); |
| 82 |
+#else |
| 83 |
+ return Name.starts_with(TmpVarNamePrefix) || |
| 84 |
+ Name.starts_with(PrintedVarNamePrefix) || |
| 85 |
+ Name.starts_with(CheckedVarNamePrefix); |
| 86 |
+#endif |
| 87 |
} |
| 88 |
|
| 89 |
// Reference: IdenticalExprChecker.cpp from Clang |
| 90 |
@@ -524,8 +559,13 @@ bool ExpressionDetector::isValidExpr(Stm |
| 91 |
if (const DeclRefExpr *SubE = |
| 92 |
dyn_cast<DeclRefExpr>(UO->getSubExpr()->IgnoreParenCasts())) { |
| 93 |
StringRef SubEName = SubE->getDecl()->getName(); |
| 94 |
+#if LLVM_VERSION_MAJOR < 18 |
| 95 |
if (SubEName.startswith(PrintedVarNamePrefix) || |
| 96 |
SubEName.startswith(CheckedVarNamePrefix)) |
| 97 |
+#else |
| 98 |
+ if (SubEName.starts_with(PrintedVarNamePrefix) || |
| 99 |
+ SubEName.starts_with(CheckedVarNamePrefix)) |
| 100 |
+#endif |
| 101 |
return false; |
| 102 |
} |
| 103 |
} |
| 104 |
@@ -541,7 +581,11 @@ bool ExpressionDetector::isValidExpr(Stm |
| 105 |
bool IsLit = SC == Stmt::IntegerLiteralClass || |
| 106 |
SC == Stmt::FloatingLiteralClass; |
| 107 |
if (IsLit && DRE && |
| 108 |
+#if LLVM_VERSION_MAJOR < 18 |
| 109 |
DRE->getDecl()->getName().startswith(TmpVarNamePrefix) && |
| 110 |
+#else |
| 111 |
+ DRE->getDecl()->getName().starts_with(TmpVarNamePrefix) && |
| 112 |
+#endif |
| 113 |
S->getStmtClass() == Stmt::IfStmtClass) { |
| 114 |
return false; |
| 115 |
} |
| 116 |
--- a/clang_delta/RemoveNamespace.cpp |
| 117 |
+++ b/clang_delta/RemoveNamespace.cpp |
| 118 |
@@ -944,7 +944,11 @@ void RemoveNamespace::handleOneNamedDecl |
| 119 |
TransAssert(IdInfo && "Invalid IdentifierInfo!"); |
| 120 |
NewName += IdInfo->getName(); |
| 121 |
// Make sure we have valid suffix for user literals |
| 122 |
+#if LLVM_VERSION_MAJOR < 18 |
| 123 |
if (IsUserLiteral && IdInfo->getName().startswith("_")) { |
| 124 |
+#else |
| 125 |
+ if (IsUserLiteral && IdInfo->getName().starts_with("_")) { |
| 126 |
+#endif |
| 127 |
NewName = "_" + NewName; |
| 128 |
} |
| 129 |
NamedDeclToNewName[ND] = NewName; |
| 130 |
--- a/clang_delta/CommonRenameClassRewriteVisitor.h |
| 131 |
+++ b/clang_delta/CommonRenameClassRewriteVisitor.h |
| 132 |
@@ -368,6 +368,9 @@ bool CommonRenameClassRewriteVisitor<T>: |
| 133 |
case TemplateArgument::Null: |
| 134 |
case TemplateArgument::Declaration: |
| 135 |
case TemplateArgument::Integral: |
| 136 |
+#if LLVM_VERSION_MAJOR >= 18 |
| 137 |
+ case TemplateArgument::StructuralValue: |
| 138 |
+#endif |
| 139 |
return true; |
| 140 |
|
| 141 |
case TemplateArgument::Type: { |
| 142 |
--- a/clang_delta/RenameCXXMethod.cpp |
| 143 |
+++ b/clang_delta/RenameCXXMethod.cpp |
| 144 |
@@ -426,7 +426,7 @@ bool RenameCXXMethod::isValidName(const |
| 145 |
{ |
| 146 |
size_t PrefixLen = MethodNamePrefix.length(); |
| 147 |
StringRef NamePrefix = Name.substr(0, PrefixLen); |
| 148 |
- if (!NamePrefix.equals(MethodNamePrefix)) |
| 149 |
+ if (NamePrefix != MethodNamePrefix) |
| 150 |
return false; |
| 151 |
llvm::APInt Num; |
| 152 |
return !Name.drop_front(PrefixLen).getAsInteger(10, Num); |