diff options
author | Sean Callanan <scallanan@apple.com> | 2011-04-09 00:37:25 +0000 |
---|---|---|
committer | Sean Callanan <scallanan@apple.com> | 2011-04-09 00:37:25 +0000 |
commit | 457856c03f2f0edb2e218fc91851623a1e6dbdbb (patch) | |
tree | c8cc6ba85be25657ee47cf179d4490c2f8edcf3d /lib/MC | |
parent | 052aa2c256acebab662b6099b155057d4092c3cf (diff) | |
download | external_llvm-457856c03f2f0edb2e218fc91851623a1e6dbdbb.zip external_llvm-457856c03f2f0edb2e218fc91851623a1e6dbdbb.tar.gz external_llvm-457856c03f2f0edb2e218fc91851623a1e6dbdbb.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129177 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC')
-rw-r--r-- | lib/MC/MCDisassembler/EDDisassembler.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/MC/MCDisassembler/EDDisassembler.cpp b/lib/MC/MCDisassembler/EDDisassembler.cpp index e36b3a4..91c5284 100644 --- a/lib/MC/MCDisassembler/EDDisassembler.cpp +++ b/lib/MC/MCDisassembler/EDDisassembler.cpp @@ -334,6 +334,15 @@ int EDDisassembler::printInst(std::string &str, MCInst &inst) { 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 @@ int EDDisassembler::parseInst(SmallVectorImpl<MCParsedAsmOperand*> &operands, 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)); |