[llvm] 3ca232f - [TableGen] CodeEmitterGen - emit report_fatal_error(const char*) instead of report_fatal_error(std::string&)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 5 09:05:11 PDT 2021


Author: Simon Pilgrim
Date: 2021-10-05T17:03:18+01:00
New Revision: 3ca232feb3526281bf9640f5f6f21e8f4c622b28

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

LOG: [TableGen] CodeEmitterGen - emit report_fatal_error(const char*) instead of report_fatal_error(std::string&)

As described on D111049, we're trying to remove the <string> dependency from error handling. In most cases the plan is to use the Twine() variant directly but to reduce introducing additional headers for the generated files, I'm using the const char* variant here instead.

Added: 
    

Modified: 
    llvm/utils/TableGen/CodeEmitterGen.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/utils/TableGen/CodeEmitterGen.cpp b/llvm/utils/TableGen/CodeEmitterGen.cpp
index ffc2878d35082..ee77ef5eda5fc 100644
--- a/llvm/utils/TableGen/CodeEmitterGen.cpp
+++ b/llvm/utils/TableGen/CodeEmitterGen.cpp
@@ -515,7 +515,7 @@ void CodeEmitterGen::run(raw_ostream &o) {
     << "    std::string msg;\n"
     << "    raw_string_ostream Msg(msg);\n"
     << "    Msg << \"Not supported instr: \" << MI;\n"
-    << "    report_fatal_error(Msg.str());\n"
+    << "    report_fatal_error(Msg.str().c_str());\n"
     << "  }\n";
   if (UseAPInt)
     o << "  Inst = Value;\n";
@@ -638,7 +638,7 @@ void CodeEmitterGen::run(raw_ostream &o) {
     << "      if (MissingFeatures.test(i))\n"
     << "        Msg << SubtargetFeatureNames[i] << \" \";\n"
     << "    Msg << \"predicate(s) are not met\";\n"
-    << "    report_fatal_error(Msg.str());\n"
+    << "    report_fatal_error(Msg.str().c_str());\n"
     << "  }\n"
     << "#else\n"
     << "  // Silence unused variable warning on targets that don't use MCII for "


        


More information about the llvm-commits mailing list