[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:54:02 PDT 2025


================
@@ -7,9 +7,28 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/MC/MCCodeEmitter.h"
+#include "llvm/MC/MCInst.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
+#include <string>
 
 using namespace llvm;
 
 MCCodeEmitter::MCCodeEmitter() = default;
 
 MCCodeEmitter::~MCCodeEmitter() = default;
+
+void MCCodeEmitter::reportUnsupportedInst(const MCInst &Inst) {
+  std::string Msg;
+  raw_string_ostream OS(Msg);
+  OS << "Unsupported instruction : " << Inst;
+  report_fatal_error(Msg.c_str());
----------------
s-barannikov wrote:

report_fatal_error is soft-deprecated. It should be replaced with either reportFatalInternalError or reportFatalUsage error, whichever is appropriate.
(nit) Both of them support Twine argument, so the string stream isn't really necessary here.

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


More information about the llvm-commits mailing list