Skip to content

Commit e244a6f

Browse files
committed
[mlir] Replace report_fatal_error(std::string) uses with report_fatal_error(Twine)
As described on D111049, we're trying to remove the <string> dependency from error handling and replace uses of report_fatal_error(const std::string&) with the Twine() variant which can be forward declared.
1 parent 00e704b commit e244a6f

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

mlir/include/mlir/IR/Builders.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ class OpBuilder : public Builder {
394394
void checkHasAbstractOperation(const OperationName &name) {
395395
if (LLVM_UNLIKELY(!name.getAbstractOperation()))
396396
llvm::report_fatal_error(
397-
"Building op `" + name.getStringRef().str() +
397+
"Building op `" + name.getStringRef() +
398398
"` but it isn't registered in this MLIRContext: the dialect may not "
399399
"be loaded or this operation isn't registered by the dialect. See "
400400
"also https://mlir.llvm.org/getting_started/Faq/"

mlir/lib/Interfaces/DataLayoutInterfaces.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ using namespace mlir;
2929
os << "neither the scoping op nor the type class provide data layout "
3030
"information for "
3131
<< type;
32-
llvm::report_fatal_error(os.str());
32+
llvm::report_fatal_error(Twine(os.str()));
3333
}
3434

3535
/// Returns the bitwidth of the index type if specified in the param list.

mlir/lib/Reducer/Tester.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,16 @@ Tester::isInteresting(ModuleOp module) const {
3939
llvm::sys::fs::createTemporaryFile("mlir-reduce", "mlir", fd, filepath);
4040

4141
if (ec)
42-
llvm::report_fatal_error("Error making unique filename: " + ec.message());
42+
llvm::report_fatal_error(llvm::Twine("Error making unique filename: ") +
43+
ec.message());
4344

4445
llvm::ToolOutputFile out(filepath, fd);
4546
module.print(out.os());
4647
out.os().close();
4748

4849
if (out.os().has_error())
49-
llvm::report_fatal_error("Error emitting the IR to file '" + filepath);
50+
llvm::report_fatal_error(llvm::Twine("Error emitting the IR to file '") +
51+
filepath);
5052

5153
size_t size = out.os().tell();
5254
return std::make_pair(isInteresting(filepath), size);
@@ -70,8 +72,8 @@ Tester::Interestingness Tester::isInteresting(StringRef testCase) const {
7072
/*SecondsToWait=*/0, /*MemoryLimit=*/0, &errMsg);
7173

7274
if (result < 0)
73-
llvm::report_fatal_error("Error running interestingness test: " + errMsg,
74-
false);
75+
llvm::report_fatal_error(
76+
llvm::Twine("Error running interestingness test: ") + errMsg, false);
7577

7678
if (!result)
7779
return Interestingness::False;

0 commit comments

Comments
 (0)