summaryrefslogtreecommitdiff
path: root/lib/MC/MCContext.cpp
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
commit82f4ce5081fc9cfbf34bbe61eb0412e7ca4dc3df (patch)
treef2f2b3b4edb43f23ad81386d77fe0252ebe1c881 /lib/MC/MCContext.cpp
parent93cd59aea87a8f40f033d705cbbbfb7ab27b048f (diff)
downloadllvm-82f4ce5081fc9cfbf34bbe61eb0412e7ca4dc3df.tar.gz
llvm-82f4ce5081fc9cfbf34bbe61eb0412e7ca4dc3df.tar.bz2
llvm-82f4ce5081fc9cfbf34bbe61eb0412e7ca4dc3df.tar.xz
Add simple support for keeping MCFixup source information.
Can be used to issue more user friendly diagnostics for faulty relocation constructs and such. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149092 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCContext.cpp')
-rw-r--r--lib/MC/MCContext.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/MC/MCContext.cpp b/lib/MC/MCContext.cpp
index e22a5ab1d9..d3c4fb1d7c 100644
--- a/lib/MC/MCContext.cpp
+++ b/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);
+}