[clang] cd45f1b - [Rewrite] Use std::optional in InclusionRewriter.cpp (NFC)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 9 23:21:40 PST 2022


Author: Kazu Hirata
Date: 2022-12-09T23:21:35-08:00
New Revision: cd45f1be8f9e218aebf2c20511bba6b0a5e34b96

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

LOG: [Rewrite] Use std::optional in InclusionRewriter.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/Frontend/Rewrite/InclusionRewriter.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp b/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
index 9141adec58c48..37178d12a4790 100644
--- a/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
+++ b/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
@@ -18,6 +18,7 @@
 #include "clang/Lex/Preprocessor.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/raw_ostream.h"
+#include <optional>
 
 using namespace clang;
 using namespace llvm;
@@ -252,7 +253,8 @@ bool InclusionRewriter::IsIfAtLocationTrue(SourceLocation Loc) const {
 }
 
 void InclusionRewriter::detectMainFileEOL() {
-  Optional<MemoryBufferRef> FromFile = *SM.getBufferOrNone(SM.getMainFileID());
+  std::optional<MemoryBufferRef> FromFile =
+      *SM.getBufferOrNone(SM.getMainFileID());
   assert(FromFile);
   if (!FromFile)
     return; // Should never happen, but whatever.


        


More information about the cfe-commits mailing list