[llvm] [NFC][MC][CodeEmitterGen] Extract error reporting into a helper function (PR #159778)

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 19 10:21:10 PDT 2025


================
@@ -522,11 +515,7 @@ void CodeEmitterGen::run(raw_ostream &O) {
     << "  switch (MI.getOpcode()) {\n";
   emitCaseMap(O, BitOffsetCaseMap);
   O << "  }\n"
-    << "  std::string msg;\n"
-    << "  raw_string_ostream Msg(msg);\n"
-    << "  Msg << \"Not supported instr[opcode]: \" << MI << \"[\" << OpNum "
-       "<< \"]\";\n"
-    << "  report_fatal_error(Msg.str().c_str());\n"
+    << "  ReportFatalError(MI, OpNum);\n"
----------------
s-barannikov wrote:

This is confusing. We're mixing two cases here: out-of-range opcode and out-of-range operand index. These should be two different errors (the second could be an assertion).

https://github.com/llvm/llvm-project/pull/159778


More information about the llvm-commits mailing list