[llvm-commits] [llvm] r129177 - /llvm/trunk/lib/MC/MCDisassembler/EDDisassembler.cpp
Sean Callanan
scallanan at apple.com
Fri Apr 8 17:37:25 PDT 2011
Author: spyffe
Date: Fri Apr 8 19:37:25 2011
New Revision: 129177
URL: http://llvm.org/viewvc/llvm-project?rev=129177&view=rev
Log:
Redirected errors from the AsmParser to the proper
error stream, in cases where the AsmParser is
being invoked by EDDisassembler. Before, they
were being sent to errs() because no error handler
was installed in the SourceMgr.
Modified:
llvm/trunk/lib/MC/MCDisassembler/EDDisassembler.cpp
Modified: llvm/trunk/lib/MC/MCDisassembler/EDDisassembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDisassembler/EDDisassembler.cpp?rev=129177&r1=129176&r2=129177&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCDisassembler/EDDisassembler.cpp (original)
+++ llvm/trunk/lib/MC/MCDisassembler/EDDisassembler.cpp Fri Apr 8 19:37:25 2011
@@ -334,6 +334,15 @@
return 0;
}
+static void diag_handler(const SMDiagnostic &diag,
+ void *context)
+{
+ if (context) {
+ EDDisassembler *disassembler = static_cast<EDDisassembler*>(context);
+ diag.Print("", disassembler->ErrorStream);
+ }
+}
+
int EDDisassembler::parseInst(SmallVectorImpl<MCParsedAsmOperand*> &operands,
SmallVectorImpl<AsmToken> &tokens,
const std::string &str) {
@@ -356,6 +365,7 @@
SMLoc instLoc;
SourceMgr sourceMgr;
+ sourceMgr.setDiagHandler(diag_handler, static_cast<void*>(this));
sourceMgr.AddNewSourceBuffer(buf, SMLoc()); // ownership of buf handed over
MCContext context(*AsmInfo, NULL);
OwningPtr<MCStreamer> streamer(createNullStreamer(context));
More information about the llvm-commits
mailing list