From e244a6fec7c9724bca31a49fec34400c1e4dc417 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Wed, 6 Oct 2021 12:57:04 +0100 Subject: [PATCH] [mlir] Replace report_fatal_error(std::string) uses with report_fatal_error(Twine) As described on D111049, we're trying to remove the dependency from error handling and replace uses of report_fatal_error(const std::string&) with the Twine() variant which can be forward declared. --- mlir/include/mlir/IR/Builders.h | 2 +- mlir/lib/Interfaces/DataLayoutInterfaces.cpp | 2 +- mlir/lib/Reducer/Tester.cpp | 10 ++++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h index c7aa98d..e87796e 100644 --- a/mlir/include/mlir/IR/Builders.h +++ b/mlir/include/mlir/IR/Builders.h @@ -394,7 +394,7 @@ private: void checkHasAbstractOperation(const OperationName &name) { if (LLVM_UNLIKELY(!name.getAbstractOperation())) llvm::report_fatal_error( - "Building op `" + name.getStringRef().str() + + "Building op `" + name.getStringRef() + "` but it isn't registered in this MLIRContext: the dialect may not " "be loaded or this operation isn't registered by the dialect. See " "also https://mlir.llvm.org/getting_started/Faq/" diff --git a/mlir/lib/Interfaces/DataLayoutInterfaces.cpp b/mlir/lib/Interfaces/DataLayoutInterfaces.cpp index 5a63b28..5d238a5 100644 --- a/mlir/lib/Interfaces/DataLayoutInterfaces.cpp +++ b/mlir/lib/Interfaces/DataLayoutInterfaces.cpp @@ -29,7 +29,7 @@ using namespace mlir; os << "neither the scoping op nor the type class provide data layout " "information for " << type; - llvm::report_fatal_error(os.str()); + llvm::report_fatal_error(Twine(os.str())); } /// Returns the bitwidth of the index type if specified in the param list. diff --git a/mlir/lib/Reducer/Tester.cpp b/mlir/lib/Reducer/Tester.cpp index b5531a9..e519741 100644 --- a/mlir/lib/Reducer/Tester.cpp +++ b/mlir/lib/Reducer/Tester.cpp @@ -39,14 +39,16 @@ Tester::isInteresting(ModuleOp module) const { llvm::sys::fs::createTemporaryFile("mlir-reduce", "mlir", fd, filepath); if (ec) - llvm::report_fatal_error("Error making unique filename: " + ec.message()); + llvm::report_fatal_error(llvm::Twine("Error making unique filename: ") + + ec.message()); llvm::ToolOutputFile out(filepath, fd); module.print(out.os()); out.os().close(); if (out.os().has_error()) - llvm::report_fatal_error("Error emitting the IR to file '" + filepath); + llvm::report_fatal_error(llvm::Twine("Error emitting the IR to file '") + + filepath); size_t size = out.os().tell(); return std::make_pair(isInteresting(filepath), size); @@ -70,8 +72,8 @@ Tester::Interestingness Tester::isInteresting(StringRef testCase) const { /*SecondsToWait=*/0, /*MemoryLimit=*/0, &errMsg); if (result < 0) - llvm::report_fatal_error("Error running interestingness test: " + errMsg, - false); + llvm::report_fatal_error( + llvm::Twine("Error running interestingness test: ") + errMsg, false); if (!result) return Interestingness::False; -- 2.7.4