[llvm] 7a194cf - DebugInfo: convert Optional to std::optional

Krzysztof Parzyszek via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 4 07:27:51 PST 2022


Author: Krzysztof Parzyszek
Date: 2022-12-04T09:27:07-06:00
New Revision: 7a194cfb327a9932464b8fd91c36b07f3acb0d1d

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

LOG: DebugInfo: convert Optional to std::optional

Added: 
    

Modified: 
    llvm/include/llvm/IR/DebugInfo.h
    llvm/lib/IR/DebugInfo.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/DebugInfo.h b/llvm/include/llvm/IR/DebugInfo.h
index 7e0a68b7b9383..d2df9a0738b2f 100644
--- a/llvm/include/llvm/IR/DebugInfo.h
+++ b/llvm/include/llvm/IR/DebugInfo.h
@@ -25,6 +25,7 @@
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/IntrinsicInst.h"
 #include "llvm/IR/PassManager.h"
+#include <optional>
 
 namespace llvm {
 
@@ -277,12 +278,12 @@ struct AssignmentInfo {
             SizeInBits == DL.getTypeSizeInBits(Base->getAllocatedType())) {}
 };
 
-Optional<AssignmentInfo> getAssignmentInfo(const DataLayout &DL,
-                                           const MemIntrinsic *I);
-Optional<AssignmentInfo> getAssignmentInfo(const DataLayout &DL,
-                                           const StoreInst *SI);
-Optional<AssignmentInfo> getAssignmentInfo(const DataLayout &DL,
-                                           const AllocaInst *AI);
+std::optional<AssignmentInfo> getAssignmentInfo(const DataLayout &DL,
+                                                const MemIntrinsic *I);
+std::optional<AssignmentInfo> getAssignmentInfo(const DataLayout &DL,
+                                                const StoreInst *SI);
+std::optional<AssignmentInfo> getAssignmentInfo(const DataLayout &DL,
+                                                const AllocaInst *AI);
 
 } // end namespace at
 

diff  --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index cbbdcaf18d3bb..dcdab1d39a093 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -36,6 +36,7 @@
 #include "llvm/Support/Casting.h"
 #include <algorithm>
 #include <cassert>
+#include <optional>
 #include <utility>
 
 using namespace llvm;
@@ -1746,9 +1747,9 @@ void at::deleteAll(Function *F) {
 
 /// Collect constant properies (base, size, offset) of \p StoreDest.
 /// Return None if any properties are not constants.
-static Optional<AssignmentInfo> getAssignmentInfoImpl(const DataLayout &DL,
-                                                      const Value *StoreDest,
-                                                      uint64_t SizeInBits) {
+static std::optional<AssignmentInfo>
+getAssignmentInfoImpl(const DataLayout &DL, const Value *StoreDest,
+                      uint64_t SizeInBits) {
   APInt GEPOffset(DL.getIndexTypeSizeInBits(StoreDest->getType()), 0);
   const Value *Base = StoreDest->stripAndAccumulateConstantOffsets(
       DL, GEPOffset, /*AllowNonInbounds*/ true);
@@ -1761,8 +1762,8 @@ static Optional<AssignmentInfo> getAssignmentInfoImpl(const DataLayout &DL,
   return std::nullopt;
 }
 
-Optional<AssignmentInfo> at::getAssignmentInfo(const DataLayout &DL,
-                                               const MemIntrinsic *I) {
+std::optional<AssignmentInfo> at::getAssignmentInfo(const DataLayout &DL,
+                                                    const MemIntrinsic *I) {
   const Value *StoreDest = I->getRawDest();
   // Assume 8 bit bytes.
   auto *ConstLengthInBytes = dyn_cast<ConstantInt>(I->getLength());
@@ -1773,15 +1774,15 @@ Optional<AssignmentInfo> at::getAssignmentInfo(const DataLayout &DL,
   return getAssignmentInfoImpl(DL, StoreDest, SizeInBits);
 }
 
-Optional<AssignmentInfo> at::getAssignmentInfo(const DataLayout &DL,
-                                               const StoreInst *SI) {
+std::optional<AssignmentInfo> at::getAssignmentInfo(const DataLayout &DL,
+                                                    const StoreInst *SI) {
   const Value *StoreDest = SI->getPointerOperand();
   uint64_t SizeInBits = DL.getTypeSizeInBits(SI->getValueOperand()->getType());
   return getAssignmentInfoImpl(DL, StoreDest, SizeInBits);
 }
 
-Optional<AssignmentInfo> at::getAssignmentInfo(const DataLayout &DL,
-                                               const AllocaInst *AI) {
+std::optional<AssignmentInfo> at::getAssignmentInfo(const DataLayout &DL,
+                                                    const AllocaInst *AI) {
   uint64_t SizeInBits = DL.getTypeSizeInBits(AI->getAllocatedType());
   return getAssignmentInfoImpl(DL, AI, SizeInBits);
 }
@@ -1829,7 +1830,7 @@ void at::trackAssignments(Function::iterator Start, Function::iterator End,
   for (auto BBI = Start; BBI != End; ++BBI) {
     for (Instruction &I : *BBI) {
 
-      Optional<AssignmentInfo> Info = std::nullopt;
+      std::optional<AssignmentInfo> Info = std::nullopt;
       Value *ValueComponent = nullptr;
       Value *DestComponent = nullptr;
       if (auto *AI = dyn_cast<AllocaInst>(&I)) {


        


More information about the llvm-commits mailing list