diff options
author | Kazu Hirata <kazu@google.com> | 2023-01-02 18:29:04 -0800 |
---|---|---|
committer | Kazu Hirata <kazu@google.com> | 2023-01-02 18:29:04 -0800 |
commit | b9ef5648b5db392bf358ca2cac8669a9edb7f6c5 (patch) | |
tree | a4a9c4581a5151260950b992f721ae65a691657b /lld/MinGW | |
parent | ae331245b730a2c91ecc227c4cb1198d2b3ad94e (diff) | |
download | llvm-b9ef5648b5db392bf358ca2cac8669a9edb7f6c5.zip llvm-b9ef5648b5db392bf358ca2cac8669a9edb7f6c5.tar.gz llvm-b9ef5648b5db392bf358ca2cac8669a9edb7f6c5.tar.bz2 |
[lld] Use std::optional instead of llvm::Optional (NFC)
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
Diffstat (limited to 'lld/MinGW')
-rw-r--r-- | lld/MinGW/Driver.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/lld/MinGW/Driver.cpp b/lld/MinGW/Driver.cpp index 18e493d..962e82d 100644 --- a/lld/MinGW/Driver.cpp +++ b/lld/MinGW/Driver.cpp @@ -34,7 +34,6 @@ #include "lld/Common/Memory.h" #include "lld/Common/Version.h" #include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/Optional.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Triple.h" @@ -45,6 +44,7 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/Host.h" #include "llvm/Support/Path.h" +#include <optional> #if !defined(_MSC_VER) && !defined(__MINGW32__) #include <unistd.h> @@ -115,7 +115,8 @@ opt::InputArgList MinGWOptTable::parse(ArrayRef<const char *> argv) { } // Find a file by concatenating given paths. -static Optional<std::string> findFile(StringRef path1, const Twine &path2) { +static std::optional<std::string> findFile(StringRef path1, + const Twine &path2) { SmallString<128> s; sys::path::append(s, path1, path2); if (sys::fs::exists(s)) @@ -128,7 +129,7 @@ static std::string searchLibrary(StringRef name, ArrayRef<StringRef> searchPaths, bool bStatic) { if (name.startswith(":")) { for (StringRef dir : searchPaths) - if (Optional<std::string> s = findFile(dir, name.substr(1))) + if (std::optional<std::string> s = findFile(dir, name.substr(1))) return *s; error("unable to find library -l" + name); return ""; @@ -136,19 +137,19 @@ searchLibrary(StringRef name, ArrayRef<StringRef> searchPaths, bool bStatic) { for (StringRef dir : searchPaths) { if (!bStatic) { - if (Optional<std::string> s = findFile(dir, "lib" + name + ".dll.a")) + if (std::optional<std::string> s = findFile(dir, "lib" + name + ".dll.a")) return *s; - if (Optional<std::string> s = findFile(dir, name + ".dll.a")) + if (std::optional<std::string> s = findFile(dir, name + ".dll.a")) return *s; } - if (Optional<std::string> s = findFile(dir, "lib" + name + ".a")) + if (std::optional<std::string> s = findFile(dir, "lib" + name + ".a")) + return *s; + if (std::optional<std::string> s = findFile(dir, name + ".lib")) return *s; - if (Optional<std::string> s = findFile(dir, name + ".lib")) - return *s; if (!bStatic) { - if (Optional<std::string> s = findFile(dir, "lib" + name + ".dll")) + if (std::optional<std::string> s = findFile(dir, "lib" + name + ".dll")) return *s; - if (Optional<std::string> s = findFile(dir, name + ".dll")) + if (std::optional<std::string> s = findFile(dir, name + ".dll")) return *s; } } |