summaryrefslogtreecommitdiff
path: root/lib/MC/WinCOFFStreamer.cpp
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2014-05-22 02:18:10 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2014-05-22 02:18:10 +0000
commitf4f930c7955fa1c58197dd89d4c6cbb7a9ed45ba (patch)
tree3fedc10820d3b3bbb3f829783bfb671858c3da7c /lib/MC/WinCOFFStreamer.cpp
parent424bbbbbbcadfa402b2e103e8fdec48f99af7fae (diff)
downloadllvm-f4f930c7955fa1c58197dd89d4c6cbb7a9ed45ba.tar.gz
llvm-f4f930c7955fa1c58197dd89d4c6cbb7a9ed45ba.tar.bz2
llvm-f4f930c7955fa1c58197dd89d4c6cbb7a9ed45ba.tar.xz
MC: formalise some assertions into proper errors
Now that clang can be used as an assembler via the IAS, invalid assembler inputs would cause the assertions to trigger. Although we cannot recover from the errors here, nor provide caret diagnostics, attempt to handle them slightly more gracefully by reporting a fatal error. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209387 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/WinCOFFStreamer.cpp')
-rw-r--r--lib/MC/WinCOFFStreamer.cpp31
1 files changed, 23 insertions, 8 deletions
diff --git a/lib/MC/WinCOFFStreamer.cpp b/lib/MC/WinCOFFStreamer.cpp
index 40b8dd944b..e6df4651a5 100644
--- a/lib/MC/WinCOFFStreamer.cpp
+++ b/lib/MC/WinCOFFStreamer.cpp
@@ -11,6 +11,7 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/ADT/StringExtras.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCAsmLayout.h"
@@ -125,30 +126,39 @@ void MCWinCOFFStreamer::BeginCOFFSymbolDef(MCSymbol const *Symbol) {
assert((!Symbol->isInSection() ||
Symbol->getSection().getVariant() == MCSection::SV_COFF) &&
"Got non-COFF section in the COFF backend!");
- assert(!CurSymbol && "starting new symbol definition in a symbol definition");
+
+ if (CurSymbol)
+ FatalError("starting a new symbol definition without completing the "
+ "previous one");
CurSymbol = Symbol;
}
void MCWinCOFFStreamer::EmitCOFFSymbolStorageClass(int StorageClass) {
- assert(CurSymbol && "StorageClass specified outside of symbol definition");
- assert((StorageClass & ~0xFF) == 0 &&
- "StorageClass must only have data in the first byte!");
+ if (!CurSymbol)
+ FatalError("storage class specified outside of symbol definition");
+
+ if (StorageClass & ~0xff)
+ FatalError(Twine("storage class value '") + itostr(StorageClass) +
+ "' out of range");
MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*CurSymbol);
SD.modifyFlags(StorageClass << COFF::SF_ClassShift, COFF::SF_ClassMask);
}
void MCWinCOFFStreamer::EmitCOFFSymbolType(int Type) {
- assert(CurSymbol && "SymbolType specified outside of a symbol definition");
- assert((Type & ~0xFFFF) == 0 &&
- "Type must only have data in the first 2 bytes");
+ if (!CurSymbol)
+ FatalError("symbol type specified outside of a symbol definition");
+
+ if (Type & ~0xffff)
+ FatalError(Twine("type value '") + itostr(Type) + "' out of range");
MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*CurSymbol);
SD.modifyFlags(Type << COFF::SF_TypeShift, COFF::SF_TypeMask);
}
void MCWinCOFFStreamer::EndCOFFSymbolDef() {
- assert(CurSymbol && "ending symbol definition without beginning one");
+ if (!CurSymbol)
+ FatalError("ending symbol definition without starting one");
CurSymbol = nullptr;
}
@@ -239,5 +249,10 @@ void MCWinCOFFStreamer::EmitWin64EHHandlerData() {
void MCWinCOFFStreamer::FinishImpl() {
MCObjectStreamer::FinishImpl();
}
+
+LLVM_ATTRIBUTE_NORETURN
+void MCWinCOFFStreamer::FatalError(const Twine &Msg) const {
+ getContext().FatalError(SMLoc(), Msg);
+}
}