summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC
diff options
context:
space:
mode:
authorJim Grosbach <grosbach@apple.com>2012-01-26 23:20:11 +0000
committerJim Grosbach <grosbach@apple.com>2012-01-26 23:20:11 +0000
commitb18b409258a74567cf5072c2af63e110dba9e20a (patch)
tree150ac704437cf1b58e07584f8c8b17360c92e741 /llvm/lib/MC
parent8ff25d69682835238d6dea7635fbb239ae0e3ed7 (diff)
downloadbcm5719-llvm-b18b409258a74567cf5072c2af63e110dba9e20a.tar.gz
bcm5719-llvm-b18b409258a74567cf5072c2af63e110dba9e20a.zip
Add simple support for keeping MCFixup source information.
Can be used to issue more user friendly diagnostics for faulty relocation constructs and such. llvm-svn: 149092
Diffstat (limited to 'llvm/lib/MC')
-rw-r--r--llvm/lib/MC/MCContext.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index e22a5ab1d9f..d3c4fb1d7ca 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -20,6 +20,9 @@
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/ELF.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/SourceMgr.h"
+#include "llvm/Support/Signals.h"
using namespace llvm;
typedef StringMap<const MCSectionMachO*> MachOUniqueMapTy;
@@ -321,3 +324,19 @@ bool MCContext::isValidDwarfFileNumber(unsigned FileNumber) {
return MCDwarfFiles[FileNumber] != 0;
}
+
+void MCContext::FatalError(SMLoc Loc, const Twine &Msg) {
+ // If we have a source manager and a location, use it. Otherwise just
+ // use the generic report_fatal_error().
+ if (!SrcMgr || Loc == SMLoc())
+ report_fatal_error(Msg);
+
+ // Use the source manager to print the message.
+ SrcMgr->PrintMessage(Loc, SourceMgr::DK_Error, Msg);
+
+ // If we reached here, we are failing ungracefully. Run the interrupt handlers
+ // to make sure any special cleanups get done, in particular that we remove
+ // files registered with RemoveFileOnSignal.
+ sys::RunInterruptHandlers();
+ exit(1);
+}
OpenPOWER on IntegriCloud