diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2012-01-07 03:13:18 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2012-01-07 03:13:18 +0000 |
commit | 99b4237c1647156f0e1d3d7e03efdab23ed79778 (patch) | |
tree | d42c2ee376e2ae4534420e024205edc6b7cca8fe /lib | |
parent | 977679d6034791fd48a344e5b990503ba50fc242 (diff) | |
download | external_llvm-99b4237c1647156f0e1d3d7e03efdab23ed79778.zip external_llvm-99b4237c1647156f0e1d3d7e03efdab23ed79778.tar.gz external_llvm-99b4237c1647156f0e1d3d7e03efdab23ed79778.tar.bz2 |
Split Finish into Finish and FinishImpl to have a common place to do end of
file error checking. Use that to error on an unfinished cfi_startproc.
The error is not nice, but is already better than a segmentation fault.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147717 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/MC/MCAsmStreamer.cpp | 4 | ||||
-rw-r--r-- | lib/MC/MCELFStreamer.cpp | 4 | ||||
-rw-r--r-- | lib/MC/MCELFStreamer.h | 2 | ||||
-rw-r--r-- | lib/MC/MCLoggingStreamer.cpp | 6 | ||||
-rw-r--r-- | lib/MC/MCMachOStreamer.cpp | 6 | ||||
-rw-r--r-- | lib/MC/MCNullStreamer.cpp | 2 | ||||
-rw-r--r-- | lib/MC/MCObjectStreamer.cpp | 2 | ||||
-rw-r--r-- | lib/MC/MCPureStreamer.cpp | 6 | ||||
-rw-r--r-- | lib/MC/MCStreamer.cpp | 7 | ||||
-rw-r--r-- | lib/MC/WinCOFFStreamer.cpp | 6 | ||||
-rw-r--r-- | lib/Target/PTX/PTXMCAsmStreamer.cpp | 4 |
11 files changed, 28 insertions, 21 deletions
diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp index 630a104..ca2f10e 100644 --- a/lib/MC/MCAsmStreamer.cpp +++ b/lib/MC/MCAsmStreamer.cpp @@ -255,7 +255,7 @@ public: /// indicated by the hasRawTextSupport() predicate. virtual void EmitRawText(StringRef String); - virtual void Finish(); + virtual void FinishImpl(); /// @} }; @@ -1285,7 +1285,7 @@ void MCAsmStreamer::EmitRawText(StringRef String) { EmitEOL(); } -void MCAsmStreamer::Finish() { +void MCAsmStreamer::FinishImpl() { // Dump out the dwarf file & directory tables and line tables. if (getContext().hasDwarfFiles() && !UseLoc) MCDwarfFileTable::Emit(this); diff --git a/lib/MC/MCELFStreamer.cpp b/lib/MC/MCELFStreamer.cpp index dcc4666..aaae21f 100644 --- a/lib/MC/MCELFStreamer.cpp +++ b/lib/MC/MCELFStreamer.cpp @@ -356,7 +356,7 @@ void MCELFStreamer::EmitInstToData(const MCInst &Inst) { DF->getContents().append(Code.begin(), Code.end()); } -void MCELFStreamer::Finish() { +void MCELFStreamer::FinishImpl() { EmitFrames(true); for (std::vector<LocalCommon>::const_iterator i = LocalCommons.begin(), @@ -379,7 +379,7 @@ void MCELFStreamer::Finish() { SectData.setAlignment(ByteAlignment); } - this->MCObjectStreamer::Finish(); + this->MCObjectStreamer::FinishImpl(); } MCStreamer *llvm::createELFStreamer(MCContext &Context, MCAsmBackend &MAB, diff --git a/lib/MC/MCELFStreamer.h b/lib/MC/MCELFStreamer.h index 10bf775..e28a884 100644 --- a/lib/MC/MCELFStreamer.h +++ b/lib/MC/MCELFStreamer.h @@ -94,7 +94,7 @@ public: virtual void EmitFileDirective(StringRef Filename); - virtual void Finish(); + virtual void FinishImpl(); private: virtual void EmitInstToFragment(const MCInst &Inst); diff --git a/lib/MC/MCLoggingStreamer.cpp b/lib/MC/MCLoggingStreamer.cpp index d59b6d7..18a9a94 100644 --- a/lib/MC/MCLoggingStreamer.cpp +++ b/lib/MC/MCLoggingStreamer.cpp @@ -243,9 +243,9 @@ public: return Child->EmitRawText(String); } - virtual void Finish() { - LogCall("Finish"); - return Child->Finish(); + virtual void FinishImpl() { + LogCall("FinishImpl"); + return Child->FinishImpl(); } }; diff --git a/lib/MC/MCMachOStreamer.cpp b/lib/MC/MCMachOStreamer.cpp index 50ab1f8..af0f160 100644 --- a/lib/MC/MCMachOStreamer.cpp +++ b/lib/MC/MCMachOStreamer.cpp @@ -89,7 +89,7 @@ public: //report_fatal_error("unsupported directive: '.file'"); } - virtual void Finish(); + virtual void FinishImpl(); /// @} }; @@ -375,7 +375,7 @@ void MCMachOStreamer::EmitInstToData(const MCInst &Inst) { DF->getContents().append(Code.begin(), Code.end()); } -void MCMachOStreamer::Finish() { +void MCMachOStreamer::FinishImpl() { EmitFrames(true); // We have to set the fragment atom associations so we can relax properly for @@ -407,7 +407,7 @@ void MCMachOStreamer::Finish() { } } - this->MCObjectStreamer::Finish(); + this->MCObjectStreamer::FinishImpl(); } MCStreamer *llvm::createMachOStreamer(MCContext &Context, MCAsmBackend &MAB, diff --git a/lib/MC/MCNullStreamer.cpp b/lib/MC/MCNullStreamer.cpp index ca74663..432974f 100644 --- a/lib/MC/MCNullStreamer.cpp +++ b/lib/MC/MCNullStreamer.cpp @@ -94,7 +94,7 @@ namespace { StringRef FileName) {} virtual void EmitInstruction(const MCInst &Inst) {} - virtual void Finish() {} + virtual void FinishImpl() {} /// @} }; diff --git a/lib/MC/MCObjectStreamer.cpp b/lib/MC/MCObjectStreamer.cpp index 663d0ca..76c853c 100644 --- a/lib/MC/MCObjectStreamer.cpp +++ b/lib/MC/MCObjectStreamer.cpp @@ -255,7 +255,7 @@ void MCObjectStreamer::EmitGPRel32Value(const MCExpr *Value) { DF->getContents().resize(DF->getContents().size() + 4, 0); } -void MCObjectStreamer::Finish() { +void MCObjectStreamer::FinishImpl() { // Dump out the dwarf file & directory tables and line tables. if (getContext().hasDwarfFiles()) MCDwarfFileTable::Emit(this); diff --git a/lib/MC/MCPureStreamer.cpp b/lib/MC/MCPureStreamer.cpp index 1a2a92e..20a3bdb 100644 --- a/lib/MC/MCPureStreamer.cpp +++ b/lib/MC/MCPureStreamer.cpp @@ -48,7 +48,7 @@ public: unsigned MaxBytesToEmit = 0); virtual void EmitValueToOffset(const MCExpr *Offset, unsigned char Value = 0); - virtual void Finish(); + virtual void FinishImpl(); virtual void EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) { @@ -224,10 +224,10 @@ void MCPureStreamer::EmitInstToData(const MCInst &Inst) { DF->getContents().append(Code.begin(), Code.end()); } -void MCPureStreamer::Finish() { +void MCPureStreamer::FinishImpl() { // FIXME: Handle DWARF tables? - this->MCObjectStreamer::Finish(); + this->MCObjectStreamer::FinishImpl(); } MCStreamer *llvm::createPureStreamer(MCContext &Context, MCAsmBackend &MAB, diff --git a/lib/MC/MCStreamer.cpp b/lib/MC/MCStreamer.cpp index 8567941..ce9de9d 100644 --- a/lib/MC/MCStreamer.cpp +++ b/lib/MC/MCStreamer.cpp @@ -652,3 +652,10 @@ void MCStreamer::EmitW64Tables() { MCWin64EHUnwindEmitter::Emit(*this); } + +void MCStreamer::Finish() { + if (!FrameInfos.empty() && !FrameInfos.back().End) + report_fatal_error("Unfinished frame!"); + + FinishImpl(); +} diff --git a/lib/MC/WinCOFFStreamer.cpp b/lib/MC/WinCOFFStreamer.cpp index f2fecae..265f0da 100644 --- a/lib/MC/WinCOFFStreamer.cpp +++ b/lib/MC/WinCOFFStreamer.cpp @@ -79,7 +79,7 @@ public: virtual void EmitFileDirective(StringRef Filename); virtual void EmitInstruction(const MCInst &Instruction); virtual void EmitWin64EHHandlerData(); - virtual void Finish(); + virtual void FinishImpl(); private: virtual void EmitInstToFragment(const MCInst &Inst) { @@ -401,9 +401,9 @@ void WinCOFFStreamer::EmitWin64EHHandlerData() { MCWin64EHUnwindEmitter::EmitUnwindInfo(*this, getCurrentW64UnwindInfo()); } -void WinCOFFStreamer::Finish() { +void WinCOFFStreamer::FinishImpl() { EmitW64Tables(); - MCObjectStreamer::Finish(); + MCObjectStreamer::FinishImpl(); } namespace llvm diff --git a/lib/Target/PTX/PTXMCAsmStreamer.cpp b/lib/Target/PTX/PTXMCAsmStreamer.cpp index bc7aaa3..270ed2d 100644 --- a/lib/Target/PTX/PTXMCAsmStreamer.cpp +++ b/lib/Target/PTX/PTXMCAsmStreamer.cpp @@ -176,7 +176,7 @@ public: /// indicated by the hasRawTextSupport() predicate. virtual void EmitRawText(StringRef String); - virtual void Finish(); + virtual void FinishImpl(); /// @} @@ -540,7 +540,7 @@ void PTXMCAsmStreamer::EmitRawText(StringRef String) { EmitEOL(); } -void PTXMCAsmStreamer::Finish() {} +void PTXMCAsmStreamer::FinishImpl() {} namespace llvm { MCStreamer *createPTXAsmStreamer(MCContext &Context, |