[clang-tools-extra] 30c6758 - Use value_or instead of getValueOr (NFC)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 19 10:34:55 PDT 2022
Author: Kazu Hirata
Date: 2022-06-19T10:34:41-07:00
New Revision: 30c675878c21be9973faabddc38ebf1b4c603b7d
URL: https://github.com/llvm/llvm-project/commit/30c675878c21be9973faabddc38ebf1b4c603b7d
DIFF: https://github.com/llvm/llvm-project/commit/30c675878c21be9973faabddc38ebf1b4c603b7d.diff
LOG: Use value_or instead of getValueOr (NFC)
Added:
Modified:
clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
clang-tools-extra/clangd/unittests/HeadersTests.cpp
clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
flang/include/flang/Optimizer/Dialect/FIROps.td
lldb/unittests/Core/SourceLocationSpecTest.cpp
llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
mlir/include/mlir/ExecutionEngine/MemRefUtils.h
mlir/include/mlir/Tools/PDLL/AST/Diagnostic.h
mlir/lib/Analysis/Presburger/Simplex.cpp
mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp
mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp
mlir/lib/IR/BuiltinTypes.cpp
mlir/lib/Pass/Pass.cpp
mlir/lib/Rewrite/ByteCode.cpp
mlir/lib/TableGen/AttrOrTypeDef.cpp
mlir/lib/TableGen/Constraint.cpp
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
mlir/lib/Tools/PDLL/AST/Types.cpp
mlir/lib/Tools/lsp-server-support/Transport.cpp
mlir/lib/Transforms/Utils/DialectConversion.cpp
mlir/test/lib/Dialect/Test/TestDialect.cpp
mlir/test/mlir-tblgen/attr-or-type-format.td
mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp
polly/lib/Support/ScopHelper.cpp
polly/lib/Transform/ManualOptimizer.cpp
polly/lib/Transform/ScheduleTreeTransform.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp b/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
index 6480f2f3f39bb..3fc45edd16dec 100644
--- a/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
+++ b/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
@@ -300,7 +300,7 @@ TEST(GlobalCompilationDatabaseTest, BuildDir) {
DirectoryBasedGlobalCompilationDatabase::Options Opts(FS);
return DirectoryBasedGlobalCompilationDatabase(Opts)
.getCompileCommand(testPath(Relative))
- .getValueOr(tooling::CompileCommand())
+ .value_or(tooling::CompileCommand())
.CommandLine;
};
EXPECT_THAT(Command("x/foo.cc"), IsEmpty());
diff --git a/clang-tools-extra/clangd/unittests/HeadersTests.cpp b/clang-tools-extra/clangd/unittests/HeadersTests.cpp
index a9872cfae2a02..69fcadcf0674a 100644
--- a/clang-tools-extra/clangd/unittests/HeadersTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HeadersTests.cpp
@@ -112,7 +112,7 @@ class HeadersTest : public ::testing::Test {
return "";
auto Path = Inserter.calculateIncludePath(Inserted, MainFile);
Action.EndSourceFile();
- return Path.getValueOr("");
+ return Path.value_or("");
}
llvm::Optional<TextEdit> insert(llvm::StringRef VerbatimHeader) {
diff --git a/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp b/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
index 96e0c8cd6b1d5..d7fd1a09e85d3 100644
--- a/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -376,7 +376,7 @@ class SpelledWordsTest : public ::testing::Test {
SpelledWord word(const char *Text) {
auto Result = tryWord(Text);
EXPECT_TRUE(Result) << Text;
- return Result.getValueOr(SpelledWord());
+ return Result.value_or(SpelledWord());
}
void noWord(const char *Text) { EXPECT_FALSE(tryWord(Text)) << Text; }
diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td
index bb652c10016e0..b9ba0a7a2cd24 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -2686,7 +2686,7 @@ def fir_GlobalOp : fir_Op<"global", [IsolatedFromAbove, Symbol]> {
mlir::Type resultType();
/// Return the initializer attribute if it exists, or a null attribute.
- mlir::Attribute getValueOrNull() { return getInitVal().getValueOr(mlir::Attribute()); }
+ mlir::Attribute getValueOrNull() { return getInitVal().value_or(mlir::Attribute()); }
/// Append the next initializer value to the `GlobalOp` to construct
/// the variable's initial value.
diff --git a/lldb/unittests/Core/SourceLocationSpecTest.cpp b/lldb/unittests/Core/SourceLocationSpecTest.cpp
index b79662f865f6b..089c7640cc010 100644
--- a/lldb/unittests/Core/SourceLocationSpecTest.cpp
+++ b/lldb/unittests/Core/SourceLocationSpecTest.cpp
@@ -50,7 +50,7 @@ TEST(SourceLocationSpecTest, FileLineColumnComponents) {
true);
EXPECT_TRUE(without_column);
EXPECT_EQ(fs, without_column.GetFileSpec());
- EXPECT_EQ(line, without_column.GetLine().getValueOr(0));
+ EXPECT_EQ(line, without_column.GetLine().value_or(0));
EXPECT_EQ(llvm::None, without_column.GetColumn());
EXPECT_FALSE(without_column.GetCheckInlines());
EXPECT_TRUE(without_column.GetExactMatch());
diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
index 2f6aa61325258..e808eee1ae19d 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
@@ -1607,12 +1607,12 @@ TEST(DWARFDebugInfo, TestFindRecurse) {
// Test the dwarf::toString() helper function.
auto StringOpt = toString(NameOpt);
EXPECT_TRUE(StringOpt);
- EXPECT_EQ(SpecDieName, StringOpt.getValueOr(nullptr));
+ EXPECT_EQ(SpecDieName, StringOpt.value_or(nullptr));
// Test the dwarf::toString() helper function with a default value specified.
EXPECT_EQ(SpecDieName, toString(NameOpt, nullptr));
auto LinkageNameOpt = FuncDie.findRecursively(DW_AT_linkage_name);
- EXPECT_EQ(SpecLinkageName, toString(LinkageNameOpt).getValueOr(nullptr));
+ EXPECT_EQ(SpecLinkageName, toString(LinkageNameOpt).value_or(nullptr));
// Make sure we can't extract the name from the abstract origin die when using
// DWARFDie::find() since it won't check the DW_AT_abstract_origin DIE.
@@ -1626,7 +1626,7 @@ TEST(DWARFDebugInfo, TestFindRecurse) {
// Test the dwarf::toString() helper function.
StringOpt = toString(NameOpt);
EXPECT_TRUE(StringOpt);
- EXPECT_EQ(AbsDieName, StringOpt.getValueOr(nullptr));
+ EXPECT_EQ(AbsDieName, StringOpt.value_or(nullptr));
}
TEST(DWARFDebugInfo, TestDwarfToFunctions) {
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
index f34812d45fb14..1b547bb89ef19 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
@@ -1240,7 +1240,7 @@ def LLVM_GlobalOp : LLVM_Op<"mlir.global",
}
/// Return the initializer attribute if it exists, or a null attribute.
Attribute getValueOrNull() {
- return getValue().getValueOr(Attribute());
+ return getValue().value_or(Attribute());
}
/// Return the initializer region. This may be empty, but if it is not it
/// terminates in an `llvm.return` op with the initializer value.
diff --git a/mlir/include/mlir/ExecutionEngine/MemRefUtils.h b/mlir/include/mlir/ExecutionEngine/MemRefUtils.h
index 6ab2dc1ae3c27..42f00795fe850 100644
--- a/mlir/include/mlir/ExecutionEngine/MemRefUtils.h
+++ b/mlir/include/mlir/ExecutionEngine/MemRefUtils.h
@@ -103,7 +103,7 @@ allocAligned(size_t nElements, AllocFunType allocFun = &::malloc,
llvm::Optional<uint64_t> alignment = llvm::Optional<uint64_t>()) {
assert(sizeof(T) < (1ul << 32) && "Elemental type overflows");
auto size = nElements * sizeof(T);
- auto desiredAlignment = alignment.getValueOr(nextPowerOf2(sizeof(T)));
+ auto desiredAlignment = alignment.value_or(nextPowerOf2(sizeof(T)));
assert((desiredAlignment & (desiredAlignment - 1)) == 0);
assert(desiredAlignment >= sizeof(T));
T *data = reinterpret_cast<T *>(allocFun(size + desiredAlignment));
@@ -175,7 +175,7 @@ class OwningMemRef {
} else {
memset(descriptor.data, 0,
nElements * sizeof(T) +
- alignment.getValueOr(detail::nextPowerOf2(sizeof(T))));
+ alignment.value_or(detail::nextPowerOf2(sizeof(T))));
}
}
/// Take ownership of an existing descriptor with a custom deleter.
diff --git a/mlir/include/mlir/Tools/PDLL/AST/Diagnostic.h b/mlir/include/mlir/Tools/PDLL/AST/Diagnostic.h
index 628f7dc4b3cc9..24e66f3c92d90 100644
--- a/mlir/include/mlir/Tools/PDLL/AST/Diagnostic.h
+++ b/mlir/include/mlir/Tools/PDLL/AST/Diagnostic.h
@@ -48,7 +48,7 @@ class Diagnostic {
assert(getSeverity() != Severity::DK_Note &&
"cannot attach a Note to a Note");
notes.emplace_back(
- new Diagnostic(Severity::DK_Note, noteLoc.getValueOr(location), msg));
+ new Diagnostic(Severity::DK_Note, noteLoc.value_or(location), msg));
return *notes.back();
}
diff --git a/mlir/lib/Analysis/Presburger/Simplex.cpp b/mlir/lib/Analysis/Presburger/Simplex.cpp
index d2c7b3dce6d24..92cc4d643d54b 100644
--- a/mlir/lib/Analysis/Presburger/Simplex.cpp
+++ b/mlir/lib/Analysis/Presburger/Simplex.cpp
@@ -868,7 +868,7 @@ Optional<SimplexBase::Pivot> Simplex::findPivot(int row,
Direction newDirection =
tableau(row, *col) < 0 ? flippedDirection(direction) : direction;
Optional<unsigned> maybePivotRow = findPivotRow(row, newDirection, *col);
- return Pivot{maybePivotRow.getValueOr(row), *col};
+ return Pivot{maybePivotRow.value_or(row), *col};
}
/// Swap the associated unknowns for the row and the column.
diff --git a/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp b/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp
index 97b631afc33cd..750ec9b02cdc8 100644
--- a/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp
+++ b/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp
@@ -596,7 +596,7 @@ struct GlobalMemrefOpLowering
initialValue = elementsAttr.getSplatValue<Attribute>();
}
- uint64_t alignment = global.alignment().getValueOr(0);
+ uint64_t alignment = global.alignment().value_or(0);
auto newGlobal = rewriter.replaceOpWithNewOp<LLVM::GlobalOp>(
global, arrayTy, global.constant(), linkage, global.sym_name(),
diff --git a/mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp b/mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp
index 2df97bd1cc087..7a419ae24301a 100644
--- a/mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp
+++ b/mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp
@@ -448,10 +448,10 @@ static void computeDirectionVector(
(*dependenceComponents)[j].op = commonLoops[j].getOperation();
auto lbConst = dependenceDomain->getConstantBound(IntegerPolyhedron::LB, j);
(*dependenceComponents)[j].lb =
- lbConst.getValueOr(std::numeric_limits<int64_t>::min());
+ lbConst.value_or(std::numeric_limits<int64_t>::min());
auto ubConst = dependenceDomain->getConstantBound(IntegerPolyhedron::UB, j);
(*dependenceComponents)[j].ub =
- ubConst.getValueOr(std::numeric_limits<int64_t>::max());
+ ubConst.value_or(std::numeric_limits<int64_t>::max());
}
}
diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
index 70437c6caa193..5665ade10c6df 100644
--- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
+++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
@@ -100,7 +100,7 @@ static void buildStructuredOp(OpBuilder &b, OperationState &state,
RegionBuilderFn regionBuilder) {
// Derive the result types if needed.
SmallVector<Type> derivedResultTypes =
- resultTensorTypes.getValueOr(TypeRange());
+ resultTensorTypes.value_or(TypeRange());
if (!resultTensorTypes.hasValue())
copy_if(outputs.getTypes(), std::back_inserter(derivedResultTypes),
[](Type type) { return type.isa<RankedTensorType>(); });
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp b/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp
index ed7d32bd6f8fc..f2fccc21db9ca 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp
@@ -148,7 +148,7 @@ LinalgOpInstancePromotionOptions::LinalgOpInstancePromotionOptions(
alignment(options.alignment) {
assert(linalgOp.hasBufferSemantics() && "revisit usage of shaped operand");
auto vUseFullTileBuffers =
- options.useFullTileBuffers.getValueOr(llvm::SmallBitVector());
+ options.useFullTileBuffers.value_or(llvm::SmallBitVector());
vUseFullTileBuffers.resize(linalgOp.getNumInputsAndOutputs(),
options.useFullTileBuffersDefault);
diff --git a/mlir/lib/IR/BuiltinTypes.cpp b/mlir/lib/IR/BuiltinTypes.cpp
index 841da97d03f99..3cebf78e4545d 100644
--- a/mlir/lib/IR/BuiltinTypes.cpp
+++ b/mlir/lib/IR/BuiltinTypes.cpp
@@ -258,7 +258,7 @@ void VectorType::walkImmediateSubElements(
VectorType VectorType::cloneWith(Optional<ArrayRef<int64_t>> shape,
Type elementType) const {
- return VectorType::get(shape.getValueOr(getShape()), elementType,
+ return VectorType::get(shape.value_or(getShape()), elementType,
getNumScalableDims());
}
@@ -290,8 +290,8 @@ TensorType TensorType::cloneWith(Optional<ArrayRef<int64_t>> shape,
if (!shape)
return RankedTensorType::get(rankedTy.getShape(), elementType,
rankedTy.getEncoding());
- return RankedTensorType::get(shape.getValueOr(rankedTy.getShape()),
- elementType, rankedTy.getEncoding());
+ return RankedTensorType::get(shape.value_or(rankedTy.getShape()), elementType,
+ rankedTy.getEncoding());
}
// Check if "elementType" can be an element type of a tensor.
diff --git a/mlir/lib/Pass/Pass.cpp b/mlir/lib/Pass/Pass.cpp
index b17a7a8cdf6da..c33d9233474f9 100644
--- a/mlir/lib/Pass/Pass.cpp
+++ b/mlir/lib/Pass/Pass.cpp
@@ -145,7 +145,7 @@ struct OpPassManagerImpl {
/// of an operation, or the result of `getAnyOpAnchorName()` in the case of an
/// op-agnostic pass manager.
StringRef getOpAnchorName() const {
- return getOpName().getValueOr(OpPassManager::getAnyOpAnchorName());
+ return getOpName().value_or(OpPassManager::getAnyOpAnchorName());
}
/// Indicate if the current pass manager can be scheduled on the given
diff --git a/mlir/lib/Rewrite/ByteCode.cpp b/mlir/lib/Rewrite/ByteCode.cpp
index ad4c078f2e3a5..7125dd34a2fae 100644
--- a/mlir/lib/Rewrite/ByteCode.cpp
+++ b/mlir/lib/Rewrite/ByteCode.cpp
@@ -919,7 +919,7 @@ void Generator::generate(pdl_interp::GetOperandsOp op, ByteCodeWriter &writer) {
Value result = op.getValue();
Optional<uint32_t> index = op.getIndex();
writer.append(OpCode::GetOperands,
- index.getValueOr(std::numeric_limits<uint32_t>::max()),
+ index.value_or(std::numeric_limits<uint32_t>::max()),
op.getInputOp());
if (result.getType().isa<pdl::RangeType>())
writer.append(getRangeStorageIndex(result));
@@ -939,7 +939,7 @@ void Generator::generate(pdl_interp::GetResultsOp op, ByteCodeWriter &writer) {
Value result = op.getValue();
Optional<uint32_t> index = op.getIndex();
writer.append(OpCode::GetResults,
- index.getValueOr(std::numeric_limits<uint32_t>::max()),
+ index.value_or(std::numeric_limits<uint32_t>::max()),
op.getInputOp());
if (result.getType().isa<pdl::RangeType>())
writer.append(getRangeStorageIndex(result));
diff --git a/mlir/lib/TableGen/AttrOrTypeDef.cpp b/mlir/lib/TableGen/AttrOrTypeDef.cpp
index 8467af0ee74c0..7d335abaeba97 100644
--- a/mlir/lib/TableGen/AttrOrTypeDef.cpp
+++ b/mlir/lib/TableGen/AttrOrTypeDef.cpp
@@ -225,8 +225,7 @@ Optional<StringRef> AttrOrTypeParameter::getAllocator() const {
}
StringRef AttrOrTypeParameter::getComparator() const {
- return getDefValue<llvm::StringInit>("comparator")
- .getValueOr("$_lhs == $_rhs");
+ return getDefValue<llvm::StringInit>("comparator").value_or("$_lhs == $_rhs");
}
StringRef AttrOrTypeParameter::getCppType() const {
@@ -242,12 +241,11 @@ StringRef AttrOrTypeParameter::getCppType() const {
StringRef AttrOrTypeParameter::getCppAccessorType() const {
return getDefValue<llvm::StringInit>("cppAccessorType")
- .getValueOr(getCppType());
+ .value_or(getCppType());
}
StringRef AttrOrTypeParameter::getCppStorageType() const {
- return getDefValue<llvm::StringInit>("cppStorageType")
- .getValueOr(getCppType());
+ return getDefValue<llvm::StringInit>("cppStorageType").value_or(getCppType());
}
Optional<StringRef> AttrOrTypeParameter::getParser() const {
@@ -265,12 +263,12 @@ Optional<StringRef> AttrOrTypeParameter::getSummary() const {
StringRef AttrOrTypeParameter::getSyntax() const {
if (auto *stringType = dyn_cast<llvm::StringInit>(getDef()))
return stringType->getValue();
- return getDefValue<llvm::StringInit>("syntax").getValueOr(getCppType());
+ return getDefValue<llvm::StringInit>("syntax").value_or(getCppType());
}
bool AttrOrTypeParameter::isOptional() const {
// Parameters with default values are automatically optional.
- return getDefValue<llvm::BitInit>("isOptional").getValueOr(false) ||
+ return getDefValue<llvm::BitInit>("isOptional").value_or(false) ||
getDefaultValue().hasValue();
}
diff --git a/mlir/lib/TableGen/Constraint.cpp b/mlir/lib/TableGen/Constraint.cpp
index bc7784c53037c..071262ab61801 100644
--- a/mlir/lib/TableGen/Constraint.cpp
+++ b/mlir/lib/TableGen/Constraint.cpp
@@ -58,7 +58,7 @@ StringRef Constraint::getSummary() const {
}
StringRef Constraint::getDescription() const {
- return def->getValueAsOptionalString("description").getValueOr("");
+ return def->getValueAsOptionalString("description").value_or("");
}
StringRef Constraint::getDefName() const {
diff --git a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index d90342f3f0f08..9126ca3848311 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -371,7 +371,7 @@ convertOmpCritical(Operation &opInst, llvm::IRBuilderBase &builder,
static_cast<int>(criticalDeclareOp.hint_val()));
}
builder.restoreIP(moduleTranslation.getOpenMPBuilder()->createCritical(
- ompLoc, bodyGenCB, finiCB, criticalOp.name().getValueOr(""), hint));
+ ompLoc, bodyGenCB, finiCB, criticalOp.name().value_or(""), hint));
return success();
}
@@ -687,8 +687,7 @@ convertOmpWsLoop(Operation &opInst, llvm::IRBuilderBase &builder,
return failure();
// Static is the default.
- auto schedule =
- loop.schedule_val().getValueOr(omp::ClauseScheduleKind::Static);
+ auto schedule = loop.schedule_val().value_or(omp::ClauseScheduleKind::Static);
// Find the loop configuration.
llvm::Value *step = moduleTranslation.lookupValue(loop.step()[0]);
diff --git a/mlir/lib/Tools/PDLL/AST/Types.cpp b/mlir/lib/Tools/PDLL/AST/Types.cpp
index 02b01e8854aae..55351154d93b8 100644
--- a/mlir/lib/Tools/PDLL/AST/Types.cpp
+++ b/mlir/lib/Tools/PDLL/AST/Types.cpp
@@ -73,7 +73,7 @@ OperationType OperationType::get(Context &context, Optional<StringRef> name,
const ods::Operation *odsOp) {
return context.getTypeUniquer().get<ImplTy>(
/*initFn=*/function_ref<void(ImplTy *)>(),
- std::make_pair(name.getValueOr(""), odsOp));
+ std::make_pair(name.value_or(""), odsOp));
}
Optional<StringRef> OperationType::getName() const {
diff --git a/mlir/lib/Tools/lsp-server-support/Transport.cpp b/mlir/lib/Tools/lsp-server-support/Transport.cpp
index 9a64938281dda..0b4c74e1ce529 100644
--- a/mlir/lib/Tools/lsp-server-support/Transport.cpp
+++ b/mlir/lib/Tools/lsp-server-support/Transport.cpp
@@ -153,7 +153,7 @@ static llvm::json::Object encodeError(llvm::Error error) {
/// Decode the given JSON object into an error.
llvm::Error decodeError(const llvm::json::Object &o) {
- StringRef msg = o.getString("message").getValueOr("Unspecified error");
+ StringRef msg = o.getString("message").value_or("Unspecified error");
if (Optional<int64_t> code = o.getInteger("code"))
return llvm::make_error<LSPError>(msg.str(), ErrorCode(*code));
return llvm::make_error<llvm::StringError>(llvm::inconvertibleErrorCode(),
diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index 575b3cbd3c335..6582be4de4e08 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -3151,7 +3151,7 @@ auto ConversionTarget::isLegal(Operation *op) const
auto legalityFnIt = opRecursiveLegalityFns.find(op->getName());
if (legalityFnIt != opRecursiveLegalityFns.end()) {
legalityDetails.isRecursivelyLegal =
- legalityFnIt->second(op).getValueOr(true);
+ legalityFnIt->second(op).value_or(true);
} else {
legalityDetails.isRecursivelyLegal = true;
}
diff --git a/mlir/test/lib/Dialect/Test/TestDialect.cpp b/mlir/test/lib/Dialect/Test/TestDialect.cpp
index ab0c543ed69d0..225d5715c2f42 100644
--- a/mlir/test/lib/Dialect/Test/TestDialect.cpp
+++ b/mlir/test/lib/Dialect/Test/TestDialect.cpp
@@ -865,7 +865,7 @@ ParseResult PrettyPrintedRegionOp::parse(OpAsmParser &parser,
// If location of the op is explicitly provided, then use it; Else use
// the parser's current location.
- Location opLoc = explicitLoc.getValueOr(currLocation);
+ Location opLoc = explicitLoc.value_or(currLocation);
// Derive the SSA-values for op's operands.
if (parser.resolveOperands(operands, opFntype.getInputs(), loc,
diff --git a/mlir/test/mlir-tblgen/attr-or-type-format.td b/mlir/test/mlir-tblgen/attr-or-type-format.td
index b84ab8a667f57..7e09f223435e3 100644
--- a/mlir/test/mlir-tblgen/attr-or-type-format.td
+++ b/mlir/test/mlir-tblgen/attr-or-type-format.td
@@ -402,7 +402,7 @@ def TypeC : TestType<"TestE"> {
}
// TYPE: ::mlir::Type TestFType::parse(::mlir::AsmParser &odsParser) {
-// TYPE: _result_a.getValueOr(int())
+// TYPE: _result_a.value_or(int())
// TYPE: void TestFType::print(::mlir::AsmPrinter &odsPrinter) const {
// TYPE if (getA()) {
@@ -501,7 +501,7 @@ def TypeH : TestType<"TestJ"> {
}
// TYPE: ::mlir::Type TestKType::parse(::mlir::AsmParser &odsParser) {
-// TYPE: _result_a.getValueOr(10)
+// TYPE: _result_a.value_or(10)
// TYPE: void TestKType::print(::mlir::AsmPrinter &odsPrinter) const {
// TYPE: if ((getA() && !(getA() == 10)))
diff --git a/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp b/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp
index a31943790aada..ba986d081e2bd 100644
--- a/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp
+++ b/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp
@@ -298,7 +298,7 @@ void DefFormat::genParser(MethodBody &os) {
for (const AttrOrTypeParameter ¶m : params) {
os << ",\n ";
if (param.isOptional()) {
- os << formatv("_result_{0}.getValueOr(", param.getName());
+ os << formatv("_result_{0}.value_or(", param.getName());
if (Optional<StringRef> defaultValue = param.getDefaultValue())
os << tgfmt(*defaultValue, &ctx);
else
diff --git a/polly/lib/Support/ScopHelper.cpp b/polly/lib/Support/ScopHelper.cpp
index 2291d34a6fb46..f9dbdb9c4d035 100644
--- a/polly/lib/Support/ScopHelper.cpp
+++ b/polly/lib/Support/ScopHelper.cpp
@@ -747,13 +747,13 @@ static Optional<bool> getOptionalBoolLoopAttribute(MDNode *LoopID,
}
bool polly::getBooleanLoopAttribute(MDNode *LoopID, StringRef Name) {
- return getOptionalBoolLoopAttribute(LoopID, Name).getValueOr(false);
+ return getOptionalBoolLoopAttribute(LoopID, Name).value_or(false);
}
llvm::Optional<int> polly::getOptionalIntLoopAttribute(MDNode *LoopID,
StringRef Name) {
const MDOperand *AttrMD =
- findNamedMetadataArg(LoopID, Name).getValueOr(nullptr);
+ findNamedMetadataArg(LoopID, Name).value_or(nullptr);
if (!AttrMD)
return None;
diff --git a/polly/lib/Transform/ManualOptimizer.cpp b/polly/lib/Transform/ManualOptimizer.cpp
index 42083f673911e..ef705eca8740c 100644
--- a/polly/lib/Transform/ManualOptimizer.cpp
+++ b/polly/lib/Transform/ManualOptimizer.cpp
@@ -96,8 +96,8 @@ static isl::schedule applyLoopUnroll(MDNode *LoopMD,
// unrolled loop could be input of another loop transformation which expects
// the explicit schedule nodes. That is, we would need this explicit expansion
// anyway and using the ISL codegen option is a compile-time optimization.
- int64_t Factor = getOptionalIntLoopAttribute(LoopMD, "llvm.loop.unroll.count")
- .getValueOr(0);
+ int64_t Factor =
+ getOptionalIntLoopAttribute(LoopMD, "llvm.loop.unroll.count").value_or(0);
bool Full = getBooleanLoopAttribute(LoopMD, "llvm.loop.unroll.full");
assert((!Full || !(Factor > 0)) &&
"Cannot unroll fully and partially at the same time");
diff --git a/polly/lib/Transform/ScheduleTreeTransform.cpp b/polly/lib/Transform/ScheduleTreeTransform.cpp
index 7c3d047d1078c..198de6f58e2b8 100644
--- a/polly/lib/Transform/ScheduleTreeTransform.cpp
+++ b/polly/lib/Transform/ScheduleTreeTransform.cpp
@@ -428,7 +428,7 @@ static bool containsExtensionNode(isl::schedule Schedule) {
/// Find a named MDNode property in a LoopID.
static MDNode *findOptionalNodeOperand(MDNode *LoopMD, StringRef Name) {
return dyn_cast_or_null<MDNode>(
- findMetadataOperand(LoopMD, Name).getValueOr(nullptr));
+ findMetadataOperand(LoopMD, Name).value_or(nullptr));
}
/// Is this node of type mark?
More information about the cfe-commits
mailing list