[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:58:40 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:

> (nit) Both of them support Twine argument, so the string stream isn't really necessary here.

Or is it not possible to wrap Inst into Twine? If so, please ignore the comment.


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


More information about the llvm-commits mailing list