Adapt llvm::Optional deprecation

This commit is contained in:
Fangrui Song 2022-12-17 20:04:54 -08:00
parent 8a93950fb9
commit 6dc564f2a8
3 changed files with 13 additions and 6 deletions

View File

@ -1097,7 +1097,9 @@ public:
void InclusionDirective(SourceLocation hashLoc, const Token &tok, void InclusionDirective(SourceLocation hashLoc, const Token &tok,
StringRef included, bool isAngled, StringRef included, bool isAngled,
CharSourceRange filenameRange, CharSourceRange filenameRange,
#if LLVM_VERSION_MAJOR >= 15 // llvmorg-15-init-7692-gd79ad2f1dbc2 #if LLVM_VERSION_MAJOR >= 16 // llvmorg-16-init-15080-g854c10f8d185
OptionalFileEntryRef fileRef,
#elif LLVM_VERSION_MAJOR >= 15 // llvmorg-15-init-7692-gd79ad2f1dbc2
llvm::Optional<FileEntryRef> fileRef, llvm::Optional<FileEntryRef> fileRef,
#else #else
const FileEntry *file, const FileEntry *file,

View File

@ -391,11 +391,14 @@ void Project::loadDirectory(const std::string &root, Project::Folder &folder) {
fwrite(input.c_str(), input.size(), 1, fout); fwrite(input.c_str(), input.size(), 1, fout);
fclose(fout); fclose(fout);
} }
std::array<Optional<StringRef>, 3> redir{StringRef(stdinPath), #if LLVM_VERSION_MAJOR >= 16 // llvmorg-16-init-12589-ge748db0f7f09
StringRef(path), StringRef()}; std::array<std::optional<StringRef>, 3>
#else
std::array<Optional<StringRef>, 3>
#endif
redir{StringRef(stdinPath), StringRef(path), StringRef()};
std::vector<StringRef> args{g_config->compilationDatabaseCommand, root}; std::vector<StringRef> args{g_config->compilationDatabaseCommand, root};
if (sys::ExecuteAndWait(args[0], args, llvm::None, redir, 0, 0, &err_msg) < if (sys::ExecuteAndWait(args[0], args, {}, redir, 0, 0, &err_msg) < 0) {
0) {
LOG_S(ERROR) << "failed to execute " << args[0].str() << " " LOG_S(ERROR) << "failed to execute " << args[0].str() << " "
<< args[1].str() << ": " << err_msg; << args[1].str() << ": " << err_msg;
return; return;

View File

@ -179,7 +179,9 @@ public:
void InclusionDirective(SourceLocation hashLoc, const Token &includeTok, void InclusionDirective(SourceLocation hashLoc, const Token &includeTok,
StringRef fileName, bool isAngled, StringRef fileName, bool isAngled,
CharSourceRange filenameRange, CharSourceRange filenameRange,
#if LLVM_VERSION_MAJOR >= 15 // llvmorg-15-init-7692-gd79ad2f1dbc2 #if LLVM_VERSION_MAJOR >= 16 // llvmorg-16-init-15080-g854c10f8d185
OptionalFileEntryRef fileRef,
#elif LLVM_VERSION_MAJOR >= 15 // llvmorg-15-init-7692-gd79ad2f1dbc2
llvm::Optional<FileEntryRef> fileRef, llvm::Optional<FileEntryRef> fileRef,
#else #else
const FileEntry *file, const FileEntry *file,