Skip to content

Commit bef481d

Browse files
committed
[mlir] Drop uses of operator<<(raw_ostream &OS, const Optional<T> &O)
1 parent 5d7c5e6 commit bef481d

File tree

10 files changed

+18
-18
lines changed

10 files changed

+18
-18
lines changed

mlir/include/mlir/Analysis/DataFlow/IntegerRangeAnalysis.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class IntegerValueRange {
3030
static IntegerValueRange getMaxRange(Value value);
3131

3232
/// Create an integer value range lattice value.
33-
IntegerValueRange(Optional<ConstantIntRanges> value = std::nullopt)
33+
IntegerValueRange(std::optional<ConstantIntRanges> value = std::nullopt)
3434
: value(std::move(value)) {}
3535

3636
/// Whether the range is uninitialized. This happens when the state hasn't
@@ -63,7 +63,7 @@ class IntegerValueRange {
6363

6464
private:
6565
/// The known integer value range.
66-
Optional<ConstantIntRanges> value;
66+
std::optional<ConstantIntRanges> value;
6767
};
6868

6969
/// This lattice element represents the integer value range of an SSA value.

mlir/include/mlir/IR/PatternMatch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class Pattern {
8989

9090
/// Return the root node that this pattern matches. Patterns that can match
9191
/// multiple root types return std::nullopt.
92-
Optional<OperationName> getRootKind() const {
92+
std::optional<OperationName> getRootKind() const {
9393
if (rootKind == RootKind::OperationName)
9494
return OperationName::getFromOpaquePointer(rootValue);
9595
return std::nullopt;

mlir/include/mlir/Pass/PassOptions.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class PassOptions : protected llvm::cl::SubCommand {
118118
using llvm::cl::parser<DataType>::parser;
119119

120120
/// Returns an argument name that maps to the specified value.
121-
Optional<StringRef> findArgStrForValue(const DataType &value) {
121+
std::optional<StringRef> findArgStrForValue(const DataType &value) {
122122
for (auto &it : this->Values)
123123
if (it.V.compare(value))
124124
return it.Name;
@@ -130,8 +130,8 @@ class PassOptions : protected llvm::cl::SubCommand {
130130
template <typename DataT>
131131
static void printValue(raw_ostream &os, GenericOptionParser<DataT> &parser,
132132
const DataT &value) {
133-
if (Optional<StringRef> argStr = parser.findArgStrForValue(value))
134-
os << argStr;
133+
if (std::optional<StringRef> argStr = parser.findArgStrForValue(value))
134+
os << *argStr;
135135
else
136136
llvm_unreachable("unknown data value for option");
137137
}

mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ static void printMemoryAccessAttribute(
327327
if (auto alignment = (alignmentAttrValue ? alignmentAttrValue
328328
: memoryOp.getAlignment())) {
329329
elidedAttrs.push_back(kAlignmentAttrName);
330-
printer << ", " << alignment;
330+
printer << ", " << *alignment;
331331
}
332332
}
333333
printer << "]";
@@ -360,7 +360,7 @@ static void printSourceMemoryAccessAttribute(
360360
if (auto alignment = (alignmentAttrValue ? alignmentAttrValue
361361
: memoryOp.getAlignment())) {
362362
elidedAttrs.push_back(kSourceAlignmentAttrName);
363-
printer << ", " << alignment;
363+
printer << ", " << *alignment;
364364
}
365365
}
366366
printer << "]";

mlir/lib/Rewrite/FrozenRewritePatternSet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ FrozenRewritePatternSet::FrozenRewritePatternSet(
100100
continue;
101101
}
102102

103-
if (Optional<OperationName> rootName = pat->getRootKind()) {
103+
if (std::optional<OperationName> rootName = pat->getRootKind()) {
104104
impl->nativeOpSpecificPatternMap[*rootName].push_back(pat.get());
105105
impl->nativeOpSpecificPatternList.push_back(std::move(pat));
106106
continue;

mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ PDLDocument::buildHoverForCoreConstraint(const ast::CoreConstraintDecl *decl,
553553
.Case([&](const ast::OpConstraintDecl *opCst) {
554554
hoverOS << "Op";
555555
if (Optional<StringRef> name = opCst->getName())
556-
hoverOS << "<" << name << ">";
556+
hoverOS << "<" << *name << ">";
557557
})
558558
.Case([&](const ast::TypeConstraintDecl *) { hoverOS << "Type"; })
559559
.Case([&](const ast::TypeRangeConstraintDecl *) {

mlir/lib/Transforms/Inliner.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,8 @@ static std::string getNodeName(CallOpInterface op) {
382382
/// Return true if the specified `inlineHistoryID` indicates an inline history
383383
/// that already includes `node`.
384384
static bool inlineHistoryIncludes(
385-
CallGraphNode *node, Optional<size_t> inlineHistoryID,
386-
MutableArrayRef<std::pair<CallGraphNode *, Optional<size_t>>>
385+
CallGraphNode *node, std::optional<size_t> inlineHistoryID,
386+
MutableArrayRef<std::pair<CallGraphNode *, std::optional<size_t>>>
387387
inlineHistory) {
388388
while (inlineHistoryID.has_value()) {
389389
assert(inlineHistoryID.value() < inlineHistory.size() &&
@@ -488,7 +488,7 @@ static LogicalResult inlineCallsInSCC(Inliner &inliner, CGUseList &useList,
488488
// When inlining a callee produces new call sites, we want to keep track of
489489
// the fact that they were inlined from the callee. This allows us to avoid
490490
// infinite inlining.
491-
using InlineHistoryT = Optional<size_t>;
491+
using InlineHistoryT = std::optional<size_t>;
492492
SmallVector<std::pair<CallGraphNode *, InlineHistoryT>, 8> inlineHistory;
493493
std::vector<InlineHistoryT> callHistory(calls.size(), InlineHistoryT{});
494494

mlir/lib/Transforms/Utils/DialectConversion.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2146,7 +2146,7 @@ void OperationLegalizer::buildLegalizationGraph(
21462146

21472147
// Build the mapping from operations to the parent ops that may generate them.
21482148
applicator.walkAllPatterns([&](const Pattern &pattern) {
2149-
Optional<OperationName> root = pattern.getRootKind();
2149+
std::optional<OperationName> root = pattern.getRootKind();
21502150

21512151
// If the pattern has no specific root, we can't analyze the relationship
21522152
// between the root op and generated operations. Given that, add all such
@@ -2228,7 +2228,7 @@ void OperationLegalizer::computeLegalizationGraphBenefit(
22282228
// decreasing benefit.
22292229
applicator.applyCostModel([&](const Pattern &pattern) {
22302230
ArrayRef<const Pattern *> orderedPatternList;
2231-
if (Optional<OperationName> rootName = pattern.getRootKind())
2231+
if (std::optional<OperationName> rootName = pattern.getRootKind())
22322232
orderedPatternList = legalizerPatterns[*rootName];
22332233
else
22342234
orderedPatternList = anyOpLegalizerPatterns;

mlir/test/lib/Analysis/DataFlow/TestDenseDataFlowAnalysis.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace {
2121
class UnderlyingValue {
2222
public:
2323
/// Create an underlying value state with a known underlying value.
24-
explicit UnderlyingValue(Optional<Value> underlyingValue = std::nullopt)
24+
explicit UnderlyingValue(std::optional<Value> underlyingValue = std::nullopt)
2525
: underlyingValue(underlyingValue) {}
2626

2727
/// Whether the state is uninitialized.
@@ -54,7 +54,7 @@ class UnderlyingValue {
5454
void print(raw_ostream &os) const { os << underlyingValue; }
5555

5656
private:
57-
Optional<Value> underlyingValue;
57+
std::optional<Value> underlyingValue;
5858
};
5959

6060
/// This lattice represents, for a given memory resource, the potential last

mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ if ({1}Iter != attrs.end()) {{
11451145
Optional<std::string> cppValue = generateExpression(assignment->value);
11461146
if (!cppValue)
11471147
return failure();
1148-
stmts.push_back(llvm::formatv("yields.push_back({0});", cppValue));
1148+
stmts.push_back(llvm::formatv("yields.push_back({0});", *cppValue));
11491149
}
11501150

11511151
if (generatedAssignmentCount != assignments.size())

0 commit comments

Comments
 (0)