aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-11-17 08:13:01 +0000
committerChris Lattner <sabre@nondot.org>2010-11-17 08:13:01 +0000
commit4afa12890f679034e9741a687a6ce33f2846f129 (patch)
tree57398005e91e5946ee1878c8322d3c1f25aaeba6 /lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
parent3f409f7fefea4d4191a914b528afe16fd7d0b4d9 (diff)
now that AsmPrinter::EmitInlineAsm is factored right, we can eliminate the
cookie argument to the SourceMgr diagnostic stuff. This cleanly separates LLVMContext's inlineasm handler from the sourcemgr error handling definition, increasing type safety and cleaning things up. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119486 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp')
-rw-r--r--lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp b/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
index 25ce25c325..9e5d679aa3 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
@@ -37,7 +37,7 @@ using namespace llvm;
namespace {
struct SrcMgrDiagInfo {
const MDNode *LocInfo;
- void *DiagHandler;
+ LLVMContext::InlineAsmDiagHandlerTy DiagHandler;
void *DiagContext;
};
}
@@ -45,8 +45,7 @@ namespace {
/// SrcMgrDiagHandler - This callback is invoked when the SourceMgr for an
/// inline asm has an error in it. diagInfo is a pointer to the SrcMgrDiagInfo
/// struct above.
-static void SrcMgrDiagHandler(const SMDiagnostic &Diag, void *diagInfo,
- unsigned locCookie) {
+static void SrcMgrDiagHandler(const SMDiagnostic &Diag, void *diagInfo) {
SrcMgrDiagInfo *DiagInfo = static_cast<SrcMgrDiagInfo *>(diagInfo);
assert(DiagInfo && "Diagnostic context not passed down?");
@@ -56,10 +55,7 @@ static void SrcMgrDiagHandler(const SMDiagnostic &Diag, void *diagInfo,
if (const ConstantInt *CI = dyn_cast<ConstantInt>(LocInfo->getOperand(0)))
LocCookie = CI->getZExtValue();
- SourceMgr::DiagHandlerTy ChainHandler =
- (SourceMgr::DiagHandlerTy)(intptr_t)DiagInfo->DiagHandler;
-
- ChainHandler(Diag, DiagInfo->DiagContext, LocCookie);
+ DiagInfo->DiagHandler(Diag, DiagInfo->DiagContext, LocCookie);
}
/// EmitInlineAsm - Emit a blob of inline asm to the output streamer.
@@ -85,11 +81,11 @@ void AsmPrinter::EmitInlineAsm(StringRef Str, const MDNode *LocMDNode) const {
// 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()) {
+ if (LLVMCtx.getInlineAsmDiagnosticHandler() != 0) {
// If the source manager has an issue, we arrange for SrcMgrDiagHandler
// to be invoked, getting DiagInfo passed into it.
DiagInfo.LocInfo = LocMDNode;
- DiagInfo.DiagHandler = DiagHandler;
+ DiagInfo.DiagHandler = LLVMCtx.getInlineAsmDiagnosticHandler();
DiagInfo.DiagContext = LLVMCtx.getInlineAsmDiagnosticContext();
SrcMgr.setDiagHandler(SrcMgrDiagHandler, &DiagInfo);
HasDiagHandler = true;