Skip to content

Commit 0f38040

Browse files
committed
[NFC] Update more APIs for std::optional
`std::optional` doesn't have `hasValue` or `getPointer`. Using the implicit decay to boolean, and grabbing the pointer to the element by expanding the optional and grabbing the reference address.
1 parent 0440029 commit 0f38040

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

lib/SIL/IR/SILInstructions.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ DifferentiableFunctionInst *DifferentiableFunctionInst::create(
814814
auto derivativeFunctions =
815815
VJPAndJVPFunctions.has_value()
816816
? ArrayRef<SILValue>(
817-
reinterpret_cast<SILValue *>(VJPAndJVPFunctions.getPointer()),
817+
reinterpret_cast<SILValue *>(&*VJPAndJVPFunctions),
818818
2)
819819
: ArrayRef<SILValue>();
820820
size_t size = totalSizeToAlloc<Operand>(1 + derivativeFunctions.size());
@@ -841,7 +841,7 @@ LinearFunctionInst::LinearFunctionInst(
841841
: InstructionBaseWithTrailingOperands(
842842
OriginalFunction,
843843
TransposeFunction.has_value()
844-
? ArrayRef<SILValue>(TransposeFunction.getPointer(), 1)
844+
? ArrayRef<SILValue>(&*TransposeFunction, 1)
845845
: ArrayRef<SILValue>(),
846846
Loc, getLinearFunctionType(OriginalFunction, ParameterIndices),
847847
forwardingOwnershipKind),

lib/SILOptimizer/Mandatory/DiagnoseStaticExclusivity.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ static void checkStaticExclusivity(SILFunction &Fn, PostOrderFunctionInfo *PO,
977977
// The in-progress accesses for the current program point, represented
978978
// as map from storage locations to the accesses in progress for the
979979
// location.
980-
State.Accesses = BBState.getPointer();
980+
State.Accesses = &*BBState;
981981
for (auto &I : *BB)
982982
checkForViolationsAtInstruction(I, State);
983983
}

lib/SILOptimizer/Transforms/SILCodeMotion.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ void BBEnumTagDataflowState::dump() const {
819819
llvm::dbgs() << "Dumping state for BB" << BB.get()->getDebugID() << "\n";
820820
llvm::dbgs() << "Block States:\n";
821821
for (auto &P : ValueToCaseMap) {
822-
if (!P.hasValue()) {
822+
if (!P) {
823823
llvm::dbgs() << " Skipping blotted value.\n";
824824
continue;
825825
}
@@ -835,7 +835,7 @@ void BBEnumTagDataflowState::dump() const {
835835
llvm::dbgs() << "Predecessor States:\n";
836836
// For each (EnumValue, [(BB, EnumTag)]) that we are tracking...
837837
for (auto &P : EnumToEnumBBCaseListMap) {
838-
if (!P.hasValue()) {
838+
if (!P) {
839839
llvm::dbgs() << " Skipping blotted value.\n";
840840
continue;
841841
}

0 commit comments

Comments
 (0)