Skip to content

Commit

Permalink
[llvm] llvm::Optional::value => operator*/operator->
Browse files Browse the repository at this point in the history
std::optional::value() has undesired exception checking semantics and is
unavailable in some older Xcode. The call sites block std::optional migration.
  • Loading branch information
MaskRay committed Dec 17, 2022
1 parent fc6ca0d commit a3209b0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions llvm/lib/Debuginfod/Debuginfod.cpp
Expand Up @@ -469,7 +469,7 @@ Expected<std::string> DebuginfodCollection::findBinaryPath(BuildIDRef ID) {
}
}
if (Path)
return Path.value();
return *Path;
}

// Try federation.
Expand Down Expand Up @@ -500,7 +500,7 @@ Expected<std::string> DebuginfodCollection::findDebugBinaryPath(BuildIDRef ID) {
}
}
if (Path)
return Path.value();
return *Path;

// Try federation.
return getCachedOrDownloadDebuginfo(ID);
Expand Down
10 changes: 4 additions & 6 deletions llvm/lib/Frontend/OpenMP/OMPContext.cpp
Expand Up @@ -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) {
Expand All @@ -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 "
Expand Down
4 changes: 2 additions & 2 deletions llvm/unittests/IR/VPIntrinsicTest.cpp
Expand Up @@ -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;
Expand All @@ -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"

Expand Down

0 comments on commit a3209b0

Please sign in to comment.