diff options
author | Chris Lattner <sabre@nondot.org> | 2010-04-06 00:55:39 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-04-06 00:55:39 +0000 |
commit | 6eb7806a5f5edf460e68f52bdd0fad25f7771873 (patch) | |
tree | d6aa37d104b4647d26244bf900282640b93fd07a /lib | |
parent | 421ccd9892178e741e24c96cef4304262475255d (diff) | |
download | external_llvm-6eb7806a5f5edf460e68f52bdd0fad25f7771873.zip external_llvm-6eb7806a5f5edf460e68f52bdd0fad25f7771873.tar.gz external_llvm-6eb7806a5f5edf460e68f52bdd0fad25f7771873.tar.bz2 |
report errors through LLVMContext's inline asm handler if available.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100509 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp b/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp index ab55b6b..a4d46c3 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp @@ -14,7 +14,10 @@ #define DEBUG_TYPE "asm-printer" #include "llvm/CodeGen/AsmPrinter.h" #include "llvm/InlineAsm.h" +#include "llvm/LLVMContext.h" +#include "llvm/Module.h" #include "llvm/CodeGen/MachineBasicBlock.h" +#include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCSymbol.h" @@ -49,6 +52,17 @@ void AsmPrinter::EmitInlineAsm(StringRef Str) const { } SourceMgr SrcMgr; + + // If the current LLVMContext has an inline asm handler, set it in SourceMgr. + LLVMContext &LLVMCtx = MMI->getModule()->getContext(); + bool HasDiagHandler = false; + if (void *DiagHandler = LLVMCtx.getInlineAsmDiagnosticHandler()) { + unsigned Cookie = 0; // no cookie yet. + SrcMgr.setDiagHandler((SourceMgr::DiagHandlerTy)(intptr_t)DiagHandler, + LLVMCtx.getInlineAsmDiagnosticContext(), Cookie); + HasDiagHandler = true; + } + MemoryBuffer *Buffer; if (isNullTerminated) Buffer = MemoryBuffer::getMemBuffer(Str, "<inline asm>"); @@ -68,7 +82,7 @@ void AsmPrinter::EmitInlineAsm(StringRef Str) const { // Don't implicitly switch to the text section before the asm. int Res = Parser.Run(/*NoInitialTextSection*/ true, /*NoFinalize*/ true); - if (Res) + if (Res && !HasDiagHandler) llvm_report_error("Error parsing inline asm\n"); } |