From 6dc564f2a8608fff778a7d7e8ed0d5acd8d61e6b Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sat, 17 Dec 2022 20:04:54 -0800 Subject: [PATCH] Adapt llvm::Optional deprecation --- src/indexer.cc | 4 +++- src/project.cc | 11 +++++++---- src/sema_manager.cc | 4 +++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/indexer.cc b/src/indexer.cc index d5fe7da2..83b77a20 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -1097,7 +1097,9 @@ public: 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 fileRef, #else const FileEntry *file, diff --git a/src/project.cc b/src/project.cc index c02bd6b6..b1b7f557 100644 --- a/src/project.cc +++ b/src/project.cc @@ -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, 3> redir{StringRef(stdinPath), - StringRef(path), StringRef()}; +#if LLVM_VERSION_MAJOR >= 16 // llvmorg-16-init-12589-ge748db0f7f09 + std::array, 3> +#else + std::array, 3> +#endif + redir{StringRef(stdinPath), StringRef(path), StringRef()}; std::vector 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; diff --git a/src/sema_manager.cc b/src/sema_manager.cc index a7b6f8ca..14f303b5 100644 --- a/src/sema_manager.cc +++ b/src/sema_manager.cc @@ -179,7 +179,9 @@ public: 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 fileRef, #else const FileEntry *file,