Add more reset methods to make all objects that the backend may use for outputting code have a reset, some are not used but were declared for completeness

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170227 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Pedro Artigas 2012-12-14 18:52:11 +00:00
parent a5ed031fbc
commit 99cbdde619
7 changed files with 40 additions and 1 deletions

View File

@ -41,6 +41,9 @@ protected: // Can only create subclasses.
public: public:
virtual ~MCAsmBackend(); virtual ~MCAsmBackend();
/// lifetime management
virtual void reset() { }
/// createObjectWriter - Create a new MCObjectWriter instance for use by the /// createObjectWriter - Create a new MCObjectWriter instance for use by the
/// assembler backend to emit the final object file. /// assembler backend to emit the final object file.
virtual MCObjectWriter *createObjectWriter(raw_ostream &OS) const = 0; virtual MCObjectWriter *createObjectWriter(raw_ostream &OS) const = 0;

View File

@ -29,6 +29,9 @@ protected: // Can only create subclasses.
public: public:
virtual ~MCCodeEmitter(); virtual ~MCCodeEmitter();
/// Lifetime management
virtual void reset() { }
/// EncodeInstruction - Encode the given \p Inst to bytes on the output /// EncodeInstruction - Encode the given \p Inst to bytes on the output
/// stream \p OS. /// stream \p OS.
virtual void EncodeInstruction(const MCInst &Inst, raw_ostream &OS, virtual void EncodeInstruction(const MCInst &Inst, raw_ostream &OS,

View File

@ -45,6 +45,13 @@ protected:
public: public:
virtual ~MCMachObjectTargetWriter(); virtual ~MCMachObjectTargetWriter();
/// @name Lifetime Management
/// @{
virtual void reset() {};
/// @}
/// @name Accessors /// @name Accessors
/// @{ /// @{
@ -111,6 +118,13 @@ public:
: MCObjectWriter(_OS, _IsLittleEndian), TargetObjectWriter(MOTW) { : MCObjectWriter(_OS, _IsLittleEndian), TargetObjectWriter(MOTW) {
} }
/// @name Lifetime management Methods
/// @{
virtual void reset();
/// @}
/// @name Utility Methods /// @name Utility Methods
/// @{ /// @{

View File

@ -51,6 +51,9 @@ protected: // Can only create subclasses.
public: public:
virtual ~MCObjectWriter(); virtual ~MCObjectWriter();
/// lifetime management
virtual void reset() { }
bool isLittleEndian() const { return IsLittleEndian; } bool isLittleEndian() const { return IsLittleEndian; }
raw_ostream &getStream() { return OS; } raw_ostream &getStream() { return OS; }

View File

@ -232,6 +232,11 @@ void MCAssembler::reset() {
RelaxAll = false; RelaxAll = false;
NoExecStack = false; NoExecStack = false;
SubsectionsViaSymbols = false; SubsectionsViaSymbols = false;
// reset objects owned by us
getBackend().reset();
getEmitter().reset();
getWriter().reset();
} }
bool MCAssembler::isSymbolLinkerVisible(const MCSymbol &Symbol) const { bool MCAssembler::isSymbolLinkerVisible(const MCSymbol &Symbol) const {

View File

@ -45,7 +45,8 @@ MCObjectStreamer::~MCObjectStreamer() {
} }
void MCObjectStreamer::reset() { void MCObjectStreamer::reset() {
Assembler->reset(); if (Assembler)
Assembler->reset();
MCStreamer::reset(); MCStreamer::reset();
} }

View File

@ -27,6 +27,16 @@
using namespace llvm; using namespace llvm;
using namespace llvm::object; using namespace llvm::object;
void MachObjectWriter::reset() {
Relocations.clear();
IndirectSymBase.clear();
StringTable.clear();
LocalSymbolData.clear();
ExternalSymbolData.clear();
UndefinedSymbolData.clear();
MCObjectWriter::reset();
}
bool MachObjectWriter:: bool MachObjectWriter::
doesSymbolRequireExternRelocation(const MCSymbolData *SD) { doesSymbolRequireExternRelocation(const MCSymbolData *SD) {
// Undefined symbols are always extern. // Undefined symbols are always extern.