Skip to content

Commit 5c9013e

Browse files
Use std::optional instead of llvm::Optional (NFC)
1 parent cbbcb10 commit 5c9013e

File tree

7 files changed

+15
-10
lines changed

7 files changed

+15
-10
lines changed

clang/lib/Analysis/UnsafeBufferUsage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ getFixIts(FixableGadgetSets &FixablesForUnsafeVars, const Strategy &S) {
615615
bool ImpossibleToFix = false;
616616
llvm::SmallVector<FixItHint, 16> FixItsForVD;
617617
for (const auto &F : Fixables) {
618-
llvm::Optional<FixItList> Fixits = F->getFixits(S);
618+
std::optional<FixItList> Fixits = F->getFixits(S);
619619
if (!Fixits) {
620620
ImpossibleToFix = true;
621621
break;

clang/unittests/Analysis/FlowSensitive/TestingSupport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ checkDataflow(AnalysisInputs<AnalysisT> AI,
262262

263263
// If successful, the dataflow analysis returns a mapping from block IDs to
264264
// the post-analysis states for the CFG blocks that have been evaluated.
265-
llvm::Expected<std::vector<llvm::Optional<TypeErasedDataflowAnalysisState>>>
265+
llvm::Expected<std::vector<std::optional<TypeErasedDataflowAnalysisState>>>
266266
MaybeBlockStates = runTypeErasedDataflowAnalysis(
267267
CFCtx, Analysis, InitEnv, TypeErasedPostVisitCFG);
268268
if (!MaybeBlockStates) return MaybeBlockStates.takeError();

mlir/include/mlir/Interfaces/Utils/InferIntRangeCommon.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "mlir/Interfaces/InferIntRangeInterface.h"
1818
#include "llvm/ADT/ArrayRef.h"
19+
#include <optional>
1920

2021
namespace mlir {
2122
namespace intrange {
@@ -117,8 +118,9 @@ enum class CmpPredicate : uint64_t {
117118
/// Returns a boolean value if `pred` is statically true or false for
118119
/// anypossible inputs falling within `lhs` and `rhs`, and std::nullopt if the
119120
/// value of the predicate cannot be determined.
120-
Optional<bool> evaluatePred(CmpPredicate pred, const ConstantIntRanges &lhs,
121-
const ConstantIntRanges &rhs);
121+
std::optional<bool> evaluatePred(CmpPredicate pred,
122+
const ConstantIntRanges &lhs,
123+
const ConstantIntRanges &rhs);
122124

123125
} // namespace intrange
124126
} // namespace mlir

mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "../GPUCommon/GPUOpsLowering.h"
3434
#include "../GPUCommon/IndexIntrinsicsOpLowering.h"
3535
#include "../GPUCommon/OpToFuncCallLowering.h"
36+
#include <optional>
3637

3738
namespace mlir {
3839
#define GEN_PASS_DEF_CONVERTGPUOPSTONVVMOPS
@@ -58,7 +59,7 @@ static NVVM::ShflKind convertShflKind(gpu::ShuffleMode mode) {
5859
llvm_unreachable("unknown shuffle mode");
5960
}
6061

61-
static Optional<NVVM::ReduxKind>
62+
static std::optional<NVVM::ReduxKind>
6263
convertReduxKind(gpu::AllReduceOperation mode) {
6364
switch (mode) {
6465
case gpu::AllReduceOperation::ADD:
@@ -95,7 +96,7 @@ struct GPUSubgroupReduceOpLowering
9596
if (!op.getValue().getType().isInteger(32))
9697
return rewriter.notifyMatchFailure(op, "unsupported data type");
9798

98-
Optional<NVVM::ReduxKind> mode = convertReduxKind(op.getOp());
99+
std::optional<NVVM::ReduxKind> mode = convertReduxKind(op.getOp());
99100
if (!mode.has_value())
100101
return rewriter.notifyMatchFailure(
101102
op, "unsupported reduction mode for redux");

mlir/lib/Dialect/Arith/IR/InferIntRangeInterfaceImpls.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ void arith::CmpIOp::inferResultRanges(ArrayRef<ConstantIntRanges> argRanges,
269269
APInt min = APInt::getZero(1);
270270
APInt max = APInt::getAllOnesValue(1);
271271

272-
Optional<bool> truthValue = intrange::evaluatePred(pred, lhs, rhs);
272+
std::optional<bool> truthValue = intrange::evaluatePred(pred, lhs, rhs);
273273
if (truthValue.has_value() && *truthValue)
274274
min = max;
275275
else if (truthValue.has_value() && !(*truthValue))

mlir/lib/Dialect/Index/IR/InferIntRangeInterfaceImpls.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "mlir/Interfaces/Utils/InferIntRangeCommon.h"
1212

1313
#include "llvm/Support/Debug.h"
14+
#include <optional>
1415

1516
#define DEBUG_TYPE "int-range-analysis"
1617

@@ -222,11 +223,11 @@ void CmpOp::inferResultRanges(ArrayRef<ConstantIntRanges> argRanges,
222223
APInt min = APInt::getZero(1);
223224
APInt max = APInt::getAllOnesValue(1);
224225

225-
Optional<bool> truthValue64 = intrange::evaluatePred(pred, lhs, rhs);
226+
std::optional<bool> truthValue64 = intrange::evaluatePred(pred, lhs, rhs);
226227

227228
ConstantIntRanges lhsTrunc = truncRange(lhs, indexMinWidth),
228229
rhsTrunc = truncRange(rhs, indexMinWidth);
229-
Optional<bool> truthValue32 =
230+
std::optional<bool> truthValue32 =
230231
intrange::evaluatePred(pred, lhsTrunc, rhsTrunc);
231232

232233
if (truthValue64 == truthValue32) {

mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "mlir/Interfaces/DestinationStyleOpInterface.h"
2525
#include "mlir/Interfaces/TilingInterface.h"
2626
#include "llvm/Support/Debug.h"
27+
#include <optional>
2728

2829
#define DEBUG_TYPE "tile-using-interface"
2930

@@ -579,7 +580,7 @@ mlir::scf::tileAndFuseProducerOfSlice(RewriterBase &rewriter,
579580
// TODO: This can be modeled better if the `DestinationStyleOpInterface`.
580581
// Update to use that when it does become available.
581582
scf::ForOp outerMostLoop = loops.front();
582-
Optional<unsigned> iterArgNumber;
583+
std::optional<unsigned> iterArgNumber;
583584
if (destinationIterArg) {
584585
iterArgNumber =
585586
outerMostLoop.getIterArgNumberForOpOperand(*destinationIterArg.value());

0 commit comments

Comments
 (0)