[clang-tools-extra] Use std::nullopt instead of None (NFC)
This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated. The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.
This is part of an effort to migrate from llvm::Optional to
std::optional:
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
diff --git a/clang-tools-extra/clangd/CompileCommands.cpp b/clang-tools-extra/clangd/CompileCommands.cpp
index 2a808b4..e88d921 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -42,7 +42,7 @@
auto Xcrun = llvm::sys::findProgramByName("xcrun");
if (!Xcrun) {
log("Couldn't find xcrun. Hopefully you have a non-apple toolchain...");
- return llvm::None;
+ return std::nullopt;
}
llvm::SmallString<64> OutFile;
llvm::sys::fs::createTemporaryFile("clangd-xcrun", "", OutFile);
@@ -58,18 +58,18 @@
"If you have a non-apple toolchain, this is OK. "
"Otherwise, try xcode-select --install.",
Ret);
- return llvm::None;
+ return std::nullopt;
}
auto Buf = llvm::MemoryBuffer::getFile(OutFile);
if (!Buf) {
log("Can't read xcrun output: {0}", Buf.getError().message());
- return llvm::None;
+ return std::nullopt;
}
StringRef Path = Buf->get()->getBuffer().trim();
if (Path.empty()) {
log("xcrun produced no output");
- return llvm::None;
+ return std::nullopt;
}
return Path.str();
}
@@ -120,12 +120,12 @@
// The effect of this is to set -isysroot correctly. We do the same.
llvm::Optional<std::string> detectSysroot() {
#ifndef __APPLE__
- return llvm::None;
+ return std::nullopt;
#endif
// SDKROOT overridden in environment, respect it. Driver will set isysroot.
if (::getenv("SDKROOT"))
- return llvm::None;
+ return std::nullopt;
return queryXcrun({"xcrun", "--show-sdk-path"});
}