[llvm] 5672b71 - [IR] Use std::optional in Module.cpp (NFC)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 25 12:06:26 PST 2022


Author: Kazu Hirata
Date: 2022-11-25T12:06:20-08:00
New Revision: 5672b714fad68dd5e589254e0f5f1ce61eb31c5b

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

LOG: [IR] Use std::optional in Module.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: 
    llvm/lib/IR/Module.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp
index 5dd114c269cc..33d71fb5ad81 100644
--- a/llvm/lib/IR/Module.cpp
+++ b/llvm/lib/IR/Module.cpp
@@ -49,6 +49,7 @@
 #include <cassert>
 #include <cstdint>
 #include <memory>
+#include <optional>
 #include <utility>
 #include <vector>
 
@@ -775,7 +776,7 @@ static VersionTuple getSDKVersionMD(Metadata *MD) {
   auto *Arr = dyn_cast_or_null<ConstantDataArray>(CM->getValue());
   if (!Arr)
     return {};
-  auto getVersionComponent = [&](unsigned Index) -> Optional<unsigned> {
+  auto getVersionComponent = [&](unsigned Index) -> std::optional<unsigned> {
     if (Index >= Arr->getNumElements())
       return None;
     return (unsigned)Arr->getElementAsInteger(Index);


        


More information about the llvm-commits mailing list