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:
virtual ~MCAsmBackend();
/// lifetime management
virtual void reset() { }
/// createObjectWriter - Create a new MCObjectWriter instance for use by the
/// assembler backend to emit the final object file.
virtual MCObjectWriter *createObjectWriter(raw_ostream &OS) const = 0;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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