[Mlir-commits] [mlir] e244a6f - [mlir] Replace report_fatal_error(std::string) uses with report_fatal_error(Twine)

Simon Pilgrim llvmlistbot at llvm.org
Wed Oct 6 04:58:34 PDT 2021


Author: Simon Pilgrim
Date: 2021-10-06T12:57:20+01:00
New Revision: e244a6fec7c9724bca31a49fec34400c1e4dc417

URL: https://github.com/llvm/llvm-project/commit/e244a6fec7c9724bca31a49fec34400c1e4dc417
DIFF: https://github.com/llvm/llvm-project/commit/e244a6fec7c9724bca31a49fec34400c1e4dc417.diff

LOG: [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.

Added: 
    

Modified: 
    mlir/include/mlir/IR/Builders.h
    mlir/lib/Interfaces/DataLayoutInterfaces.cpp
    mlir/lib/Reducer/Tester.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h
index c7aa98d7fe07c..e87796ea14046 100644
--- a/mlir/include/mlir/IR/Builders.h
+++ b/mlir/include/mlir/IR/Builders.h
@@ -394,7 +394,7 @@ class OpBuilder : public Builder {
   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 5a63b287f5f41..5d238a5bd326d 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 b5531a9a0ca02..e5197418f3e59 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;


        


More information about the Mlir-commits mailing list