/// Do automatic reset in destructor
bool AutoReset;
+ bool HadError;
+
MCSymbol *createSymbolImpl(const StringMapEntry<bool> *Name,
bool CanBeUnnamed);
MCSymbol *createSymbol(StringRef Name, bool AlwaysAddSuffix,
}
void deallocate(void *Ptr) {}
+ bool hadError() { return HadError; }
+ void reportError(SMLoc L, const Twine &Msg);
// Unrecoverable error has occurred. Display the best diagnostic we can
// and bail via exit(1). For now, most MC backend errors are unrecoverable.
// FIXME: We should really do something about that.
LLVM_ATTRIBUTE_NORETURN void reportFatalError(SMLoc L,
- const Twine &Msg) const;
+ const Twine &Msg);
};
} // end namespace llvm
CurrentDwarfLoc(0, 0, 0, DWARF2_FLAG_IS_STMT, 0, 0), DwarfLocSeen(false),
GenDwarfForAssembly(false), GenDwarfFileNumber(0), DwarfVersion(4),
AllowTemporaryLabels(true), DwarfCompileUnitID(0),
- AutoReset(DoAutoReset) {
+ AutoReset(DoAutoReset), HadError(false) {
std::error_code EC = llvm::sys::fs::current_path(CompilationDir);
if (EC)
DwarfLocSeen = false;
GenDwarfForAssembly = false;
GenDwarfFileNumber = 0;
+
+ HadError = false;
}
//===----------------------------------------------------------------------===//
[&](MCSection *Sec) { return !MCOS.mayHaveInstructions(*Sec); });
}
-void MCContext::reportFatalError(SMLoc Loc, const Twine &Msg) const {
- // If we have a source manager and a location, use it. Otherwise just
- // use the generic report_fatal_error().
- if (!SrcMgr || Loc == SMLoc())
+//===----------------------------------------------------------------------===//
+// Error Reporting
+//===----------------------------------------------------------------------===//
+
+void MCContext::reportError(SMLoc Loc, const Twine &Msg) {
+ HadError = true;
+
+ // If we have a source manager use it. Otherwise just use the generic
+ // report_fatal_error().
+ if (!SrcMgr)
report_fatal_error(Msg, false);
// Use the source manager to print the message.
SrcMgr->PrintMessage(Loc, SourceMgr::DK_Error, Msg);
+}
+
+void MCContext::reportFatalError(SMLoc Loc, const Twine &Msg) {
+ reportError(Loc, 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