--- a/clang_delta/ExpressionDetector.cpp +++ b/clang_delta/ExpressionDetector.cpp @@ -62,9 +62,20 @@ public: virtual void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName, bool IsAngled, - CharSourceRange FilenameRange, OptionalFileEntryRef File, + CharSourceRange FilenameRange, +#if LLVM_VERSION_MAJOR < 15 + const FileEntry *File, +#elif LLVM_VERSION_MAJOR < 16 + Optional File, +#else + OptionalFileEntryRef File, +#endif StringRef SearchPath, StringRef RelativePath, +#if LLVM_VERSION_MAJOR < 19 const Module *Imported, +#else + const Module *SuggestedModule, bool ModuleImported, +#endif SrcMgr::CharacteristicKind FileType) override; private: @@ -80,12 +91,22 @@ private: void IncludesPPCallbacks::InclusionDirective(SourceLocation HashLoc, const Token &/*IncludeTok*/, StringRef FileName, - bool /*IsAngled*/, + bool /*IsAngled*/, CharSourceRange /*FilenameRange*/, +#if LLVM_VERSION_MAJOR < 15 + const FileEntry * /*File*/, +#elif LLVM_VERSION_MAJOR < 16 + Optional /*File*/, +#else OptionalFileEntryRef /*File*/, +#endif StringRef /*SearchPath*/, StringRef /*RelativePath*/, - const Module * /*Imported*/, +#if LLVM_VERSION_MAJOR < 19 + const Module *Imported, +#else + const Module *SuggestedModule, bool ModuleImported, +#endif SrcMgr::CharacteristicKind /*FileType*/) { if (!SrcManager.isInMainFile(HashLoc)) @@ -118,7 +139,11 @@ bool LocalTmpVarCollector::VisitDeclRefE const VarDecl *VD = dyn_cast(DRE->getDecl()); if (!VD) return true; +#if LLVM_VERSION_MAJOR < 18 if (VD->getName().startswith(Prefix)) +#else + if (VD->getName().starts_with(Prefix)) +#endif TmpVars.push_back(VD); return true; } @@ -363,7 +388,11 @@ void ExpressionDetector::addOneTempVar(c { if (!VD) return; +#if LLVM_VERSION_MAJOR < 18 if (!VD->getName().startswith(TmpVarNamePrefix)) +#else + if (!VD->getName().starts_with(TmpVarNamePrefix)) +#endif return; if (const Expr *E = VD->getInit()) ProcessedExprs[VD] = E->IgnoreParenImpCasts(); @@ -374,9 +403,15 @@ bool ExpressionDetector::refToTmpVar(con StringRef Name = ND->getName(); // We don't want to repeatly replace temporary variables // __creduce_expr_tmp_xxx, __creduce_printed_yy and __creduce_checked_zzz. +#if LLVM_VERSION_MAJOR < 18 return Name.startswith(TmpVarNamePrefix) || Name.startswith(PrintedVarNamePrefix) || Name.startswith(CheckedVarNamePrefix); +#else + return Name.starts_with(TmpVarNamePrefix) || + Name.starts_with(PrintedVarNamePrefix) || + Name.starts_with(CheckedVarNamePrefix); +#endif } // Reference: IdenticalExprChecker.cpp from Clang @@ -524,8 +559,13 @@ bool ExpressionDetector::isValidExpr(Stm if (const DeclRefExpr *SubE = dyn_cast(UO->getSubExpr()->IgnoreParenCasts())) { StringRef SubEName = SubE->getDecl()->getName(); +#if LLVM_VERSION_MAJOR < 18 if (SubEName.startswith(PrintedVarNamePrefix) || SubEName.startswith(CheckedVarNamePrefix)) +#else + if (SubEName.starts_with(PrintedVarNamePrefix) || + SubEName.starts_with(CheckedVarNamePrefix)) +#endif return false; } } @@ -541,7 +581,11 @@ bool ExpressionDetector::isValidExpr(Stm bool IsLit = SC == Stmt::IntegerLiteralClass || SC == Stmt::FloatingLiteralClass; if (IsLit && DRE && +#if LLVM_VERSION_MAJOR < 18 DRE->getDecl()->getName().startswith(TmpVarNamePrefix) && +#else + DRE->getDecl()->getName().starts_with(TmpVarNamePrefix) && +#endif S->getStmtClass() == Stmt::IfStmtClass) { return false; } --- a/clang_delta/RemoveNamespace.cpp +++ b/clang_delta/RemoveNamespace.cpp @@ -944,7 +944,11 @@ void RemoveNamespace::handleOneNamedDecl TransAssert(IdInfo && "Invalid IdentifierInfo!"); NewName += IdInfo->getName(); // Make sure we have valid suffix for user literals +#if LLVM_VERSION_MAJOR < 18 if (IsUserLiteral && IdInfo->getName().startswith("_")) { +#else + if (IsUserLiteral && IdInfo->getName().starts_with("_")) { +#endif NewName = "_" + NewName; } NamedDeclToNewName[ND] = NewName; --- a/clang_delta/CommonRenameClassRewriteVisitor.h +++ b/clang_delta/CommonRenameClassRewriteVisitor.h @@ -368,6 +368,9 @@ bool CommonRenameClassRewriteVisitor: case TemplateArgument::Null: case TemplateArgument::Declaration: case TemplateArgument::Integral: +#if LLVM_VERSION_MAJOR >= 18 + case TemplateArgument::StructuralValue: +#endif return true; case TemplateArgument::Type: { --- a/clang_delta/RenameCXXMethod.cpp +++ b/clang_delta/RenameCXXMethod.cpp @@ -426,7 +426,7 @@ bool RenameCXXMethod::isValidName(const { size_t PrefixLen = MethodNamePrefix.length(); StringRef NamePrefix = Name.substr(0, PrefixLen); - if (!NamePrefix.equals(MethodNamePrefix)) + if (NamePrefix != MethodNamePrefix) return false; llvm::APInt Num; return !Name.drop_front(PrefixLen).getAsInteger(10, Num);