Skip to content

Commit

Permalink
Adapt llvm::Optional deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
MaskRay committed Jan 10, 2023
1 parent 8a93950 commit 6dc564f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/indexer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,9 @@ class IndexPPCallbacks : public PPCallbacks {
void InclusionDirective(SourceLocation hashLoc, const Token &tok,
StringRef included, bool isAngled,
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,
#else
const FileEntry *file,
Expand Down
11 changes: 7 additions & 4 deletions src/project.cc
Original file line number Diff line number Diff line change
Expand Up @@ -391,11 +391,14 @@ void Project::loadDirectory(const std::string &root, Project::Folder &folder) {
fwrite(input.c_str(), input.size(), 1, fout);
fclose(fout);
}
std::array<Optional<StringRef>, 3> redir{StringRef(stdinPath),
StringRef(path), StringRef()};
#if LLVM_VERSION_MAJOR >= 16 // llvmorg-16-init-12589-ge748db0f7f09
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};
if (sys::ExecuteAndWait(args[0], args, llvm::None, redir, 0, 0, &err_msg) <
0) {
if (sys::ExecuteAndWait(args[0], args, {}, redir, 0, 0, &err_msg) < 0) {
LOG_S(ERROR) << "failed to execute " << args[0].str() << " "
<< args[1].str() << ": " << err_msg;
return;
Expand Down
4 changes: 3 additions & 1 deletion src/sema_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ class StoreInclude : public PPCallbacks {
void InclusionDirective(SourceLocation hashLoc, const Token &includeTok,
StringRef fileName, bool isAngled,
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,
#else
const FileEntry *file,
Expand Down

0 comments on commit 6dc564f

Please sign in to comment.