[Analysis] Use std::optional in CFLAndersAliasAnalysis.cpp (NFC)
authorKazu Hirata <kazu@google.com>
Fri, 25 Nov 2022 18:16:32 +0000 (10:16 -0800)
committerKazu Hirata <kazu@google.com>
Fri, 25 Nov 2022 18:16:32 +0000 (10:16 -0800)
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

llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp

index d70e1b2..d9afdd0 100644 (file)
@@ -81,6 +81,7 @@
 #include <cstddef>
 #include <cstdint>
 #include <functional>
+#include <optional>
 #include <utility>
 #include <vector>
 
@@ -351,12 +352,12 @@ static bool hasWriteOnlyState(StateSet Set) {
   return (Set & StateSet(WriteOnlyStateMask)).any();
 }
 
-static Optional<InterfaceValue>
+static std::optional<InterfaceValue>
 getInterfaceValue(InstantiatedValue IValue,
                   const SmallVectorImpl<Value *> &RetVals) {
   auto Val = IValue.Val;
 
-  Optional<unsigned> Index;
+  std::optional<unsigned> Index;
   if (auto Arg = dyn_cast<Argument>(Val))
     Index = Arg->getArgNo() + 1;
   else if (is_contained(RetVals, Val))
@@ -625,7 +626,7 @@ static void initializeWorkList(std::vector<WorkListItem> &WorkList,
   }
 }
 
-static Optional<InstantiatedValue> getNodeBelow(const CFLGraph &Graph,
+static std::optional<InstantiatedValue> getNodeBelow(const CFLGraph &Graph,
                                                 InstantiatedValue V) {
   auto NodeBelow = InstantiatedValue{V.Val, V.DerefLevel + 1};
   if (Graph.getNode(NodeBelow))