[clang] 3e1856e - [Basic] Use std::optional in FileManager.cpp (NFC)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 9 22:49:52 PST 2022


Author: Kazu Hirata
Date: 2022-12-09T22:49:47-08:00
New Revision: 3e1856edb062b4e3d4848c03bac59b3c4953000e

URL: https://github.com/llvm/llvm-project/commit/3e1856edb062b4e3d4848c03bac59b3c4953000e
DIFF: https://github.com/llvm/llvm-project/commit/3e1856edb062b4e3d4848c03bac59b3c4953000e.diff

LOG: [Basic] Use std::optional in FileManager.cpp (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

Added: 
    

Modified: 
    clang/lib/Basic/FileManager.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index 69ebd3bc078d..4fefbaa01e52 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -31,6 +31,7 @@
 #include <climits>
 #include <cstdint>
 #include <cstdlib>
+#include <optional>
 #include <string>
 #include <utility>
 
@@ -123,7 +124,7 @@ FileManager::getDirectoryRef(StringRef DirName, bool CacheFailure) {
       DirName != llvm::sys::path::root_path(DirName) &&
       llvm::sys::path::is_separator(DirName.back()))
     DirName = DirName.substr(0, DirName.size()-1);
-  Optional<std::string> DirNameStr;
+  std::optional<std::string> DirNameStr;
   if (is_style_windows(llvm::sys::path::Style::native)) {
     // Fixing a problem with "clang C:test.c" on Windows.
     // Stat("C:") does not recognize "C:" as a valid directory


        


More information about the cfe-commits mailing list