[llvm] a3209b0 - [llvm] llvm::Optional::value => operator*/operator->

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 16 21:23:51 PST 2022


Author: Fangrui Song
Date: 2022-12-17T05:23:45Z
New Revision: a3209b0fbcf7c1af038cc88b5c410ca89c261a62

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

LOG: [llvm] llvm::Optional::value => operator*/operator->

std::optional::value() has undesired exception checking semantics and is
unavailable in some older Xcode. The call sites block std::optional migration.

Added: 
    

Modified: 
    llvm/lib/Debuginfod/Debuginfod.cpp
    llvm/lib/Frontend/OpenMP/OMPContext.cpp
    llvm/unittests/IR/VPIntrinsicTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Debuginfod/Debuginfod.cpp b/llvm/lib/Debuginfod/Debuginfod.cpp
index 0982b1c9c8708..17d034d52aeda 100644
--- a/llvm/lib/Debuginfod/Debuginfod.cpp
+++ b/llvm/lib/Debuginfod/Debuginfod.cpp
@@ -469,7 +469,7 @@ Expected<std::string> DebuginfodCollection::findBinaryPath(BuildIDRef ID) {
       }
     }
     if (Path)
-      return Path.value();
+      return *Path;
   }
 
   // Try federation.
@@ -500,7 +500,7 @@ Expected<std::string> DebuginfodCollection::findDebugBinaryPath(BuildIDRef ID) {
     }
   }
   if (Path)
-    return Path.value();
+    return *Path;
 
   // Try federation.
   return getCachedOrDownloadDebuginfo(ID);

diff  --git a/llvm/lib/Frontend/OpenMP/OMPContext.cpp b/llvm/lib/Frontend/OpenMP/OMPContext.cpp
index a04116041aad7..9217f8f4513c8 100644
--- a/llvm/lib/Frontend/OpenMP/OMPContext.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPContext.cpp
@@ -212,9 +212,8 @@ static int isVariantApplicableInContextHelper(
         return Ctx.matchesISATrait(RawString);
       });
 
-    Optional<bool> Result = HandleTrait(Property, IsActiveTrait);
-    if (Result)
-      return Result.value();
+    if (Optional<bool> Result = HandleTrait(Property, IsActiveTrait))
+      return *Result;
   }
 
   if (!DeviceSetOnly) {
@@ -233,9 +232,8 @@ static int isVariantApplicableInContextHelper(
       if (ConstructMatches)
         ConstructMatches->push_back(ConstructIdx - 1);
 
-      Optional<bool> Result = HandleTrait(Property, FoundInOrder);
-      if (Result)
-        return Result.value();
+      if (Optional<bool> Result = HandleTrait(Property, FoundInOrder))
+        return *Result;
 
       if (!FoundInOrder) {
         LLVM_DEBUG(dbgs() << "[" << DEBUG_TYPE << "] Construct property "

diff  --git a/llvm/unittests/IR/VPIntrinsicTest.cpp b/llvm/unittests/IR/VPIntrinsicTest.cpp
index eff437a50bbdb..6ef9ccc8ae765 100644
--- a/llvm/unittests/IR/VPIntrinsicTest.cpp
+++ b/llvm/unittests/IR/VPIntrinsicTest.cpp
@@ -169,7 +169,7 @@ TEST_F(VPIntrinsicTest, VPIntrinsicsDefScopes) {
   ScopeVPID = Intrinsic::VPID;
 #define END_REGISTER_VP_INTRINSIC(VPID)                                        \
   ASSERT_TRUE(ScopeVPID.has_value());                                          \
-  ASSERT_EQ(ScopeVPID.value(), Intrinsic::VPID);                               \
+  ASSERT_EQ(*ScopeVPID, Intrinsic::VPID);                                      \
   ScopeVPID = std::nullopt;
 
   Optional<ISD::NodeType> ScopeOPC;
@@ -178,7 +178,7 @@ TEST_F(VPIntrinsicTest, VPIntrinsicsDefScopes) {
   ScopeOPC = ISD::SDOPC;
 #define END_REGISTER_VP_SDNODE(SDOPC)                                          \
   ASSERT_TRUE(ScopeOPC.has_value());                                           \
-  ASSERT_EQ(ScopeOPC.value(), ISD::SDOPC);                                     \
+  ASSERT_EQ(*ScopeOPC, ISD::SDOPC);                                            \
   ScopeOPC = std::nullopt;
 #include "llvm/IR/VPIntrinsics.def"
 


        


More information about the llvm-commits mailing list