X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FMC%2FMCContext.cpp;h=b5ad518d0330e89f6846cee1fe0dcffc6469836d;hb=74012f5a19492f002994872f6ed1cd96383b620e;hp=ff195d0ad80377c22a207061456ab99076444e93;hpb=d546ca6a18fa62a4a8327d9733b2a5992d726910;p=oota-llvm.git diff --git a/lib/MC/MCContext.cpp b/lib/MC/MCContext.cpp index ff195d0ad80..b5ad518d033 100644 --- a/lib/MC/MCContext.cpp +++ b/lib/MC/MCContext.cpp @@ -42,7 +42,7 @@ MCContext::MCContext(const MCAsmInfo *mai, const MCRegisterInfo *mri, 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) @@ -63,9 +63,6 @@ MCContext::~MCContext() { // NOTE: The symbols are all allocated out of a bump pointer allocator, // we don't need to free them here. - - // If the stream for the .secure_log_unique directive was created free it. - delete (raw_ostream *)SecureLog; } //===----------------------------------------------------------------------===// @@ -78,8 +75,10 @@ void MCContext::reset() { ELFAllocator.DestroyAll(); MachOAllocator.DestroyAll(); + MCSubtargetAllocator.DestroyAll(); UsedNames.clear(); Symbols.clear(); + SectionSymbols.clear(); Allocator.Reset(); Instances.clear(); CompilationDir.clear(); @@ -100,6 +99,8 @@ void MCContext::reset() { DwarfLocSeen = false; GenDwarfForAssembly = false; GenDwarfFileNumber = 0; + + HadError = false; } //===----------------------------------------------------------------------===// @@ -438,6 +439,10 @@ MCSectionCOFF *MCContext::getAssociativeCOFFSection(MCSectionCOFF *Sec, COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE); } +MCSubtargetInfo &MCContext::getSubtargetCopy(const MCSubtargetInfo &STI) { + return *new (MCSubtargetAllocator.Allocate()) MCSubtargetInfo(STI); +} + //===----------------------------------------------------------------------===// // Dwarf Management //===----------------------------------------------------------------------===// @@ -469,14 +474,24 @@ void MCContext::finalizeDwarfSections(MCStreamer &MCOS) { [&](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