summaryrefslogtreecommitdiffstats
path: root/llvm/lib
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
commitb0e36085c437c71f126680b6fa38d6fc112f6471 (patch)
tree7f3b1297964a6642caca8de054acb09fa649671c /llvm/lib
parentc03d04ee1f032dafc99e2aebbfde80f68f876797 (diff)
downloadbcm5719-llvm-b0e36085c437c71f126680b6fa38d6fc112f6471.tar.gz
bcm5719-llvm-b0e36085c437c71f126680b6fa38d6fc112f6471.zip
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. llvm-svn: 119486
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp14
-rw-r--r--llvm/lib/Support/SourceMgr.cpp3
-rw-r--r--llvm/lib/VMCore/LLVMContext.cpp11
-rw-r--r--llvm/lib/VMCore/LLVMContextImpl.h3
4 files changed, 14 insertions, 17 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
index 25ce25c325e..9e5d679aa3c 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
+++ b/llvm/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;
diff --git a/llvm/lib/Support/SourceMgr.cpp b/llvm/lib/Support/SourceMgr.cpp
index 3800753ecdc..0dc1331d260 100644
--- a/llvm/lib/Support/SourceMgr.cpp
+++ b/llvm/lib/Support/SourceMgr.cpp
@@ -178,8 +178,7 @@ void SourceMgr::PrintMessage(SMLoc Loc, const Twine &Msg,
const char *Type, bool ShowLine) const {
// Report the message with the diagnostic handler if present.
if (DiagHandler) {
- DiagHandler(GetMessage(Loc, Msg, Type, ShowLine),
- DiagContext, DiagLocCookie);
+ DiagHandler(GetMessage(Loc, Msg, Type, ShowLine), DiagContext);
return;
}
diff --git a/llvm/lib/VMCore/LLVMContext.cpp b/llvm/lib/VMCore/LLVMContext.cpp
index 15ae0ec5d5a..41806999ba5 100644
--- a/llvm/lib/VMCore/LLVMContext.cpp
+++ b/llvm/lib/VMCore/LLVMContext.cpp
@@ -53,15 +53,17 @@ void LLVMContext::removeModule(Module *M) {
// Recoverable Backend Errors
//===----------------------------------------------------------------------===//
-void LLVMContext::setInlineAsmDiagnosticHandler(void *DiagHandler,
- void *DiagContext) {
+void LLVMContext::
+setInlineAsmDiagnosticHandler(InlineAsmDiagHandlerTy DiagHandler,
+ void *DiagContext) {
pImpl->InlineAsmDiagHandler = DiagHandler;
pImpl->InlineAsmDiagContext = DiagContext;
}
/// getInlineAsmDiagnosticHandler - Return the diagnostic handler set by
/// setInlineAsmDiagnosticHandler.
-void *LLVMContext::getInlineAsmDiagnosticHandler() const {
+LLVMContext::InlineAsmDiagHandlerTy
+LLVMContext::getInlineAsmDiagnosticHandler() const {
return pImpl->InlineAsmDiagHandler;
}
@@ -95,8 +97,7 @@ void LLVMContext::emitError(unsigned LocCookie, StringRef ErrorStr) {
// If we do have an error handler, we can report the error and keep going.
SMDiagnostic Diag("", "error: " + ErrorStr.str());
- ((SourceMgr::DiagHandlerTy)(intptr_t)pImpl->InlineAsmDiagHandler)
- (Diag, pImpl->InlineAsmDiagContext, LocCookie);
+ pImpl->InlineAsmDiagHandler(Diag, pImpl->InlineAsmDiagContext, LocCookie);
}
diff --git a/llvm/lib/VMCore/LLVMContextImpl.h b/llvm/lib/VMCore/LLVMContextImpl.h
index faeebb6704d..23971aafa74 100644
--- a/llvm/lib/VMCore/LLVMContextImpl.h
+++ b/llvm/lib/VMCore/LLVMContextImpl.h
@@ -119,7 +119,8 @@ public:
/// will be automatically deleted if this context is deleted.
SmallPtrSet<Module*, 4> OwnedModules;
- void *InlineAsmDiagHandler, *InlineAsmDiagContext;
+ LLVMContext::InlineAsmDiagHandlerTy InlineAsmDiagHandler;
+ void *InlineAsmDiagContext;
typedef DenseMap<DenseMapAPIntKeyInfo::KeyTy, ConstantInt*,
DenseMapAPIntKeyInfo> IntMapTy;
OpenPOWER on IntegriCloud