[PECOFF] Rename IdataPassFile and move it to Atoms.h.

I'm planning to create a new pass for the DLL export table, and I want to use
the class both from IdataPass and the new pass, EdataPass. So move the class to
a common place.

llvm-svn: 197132
This commit is contained in:
Rui Ueyama 2013-12-12 06:58:00 +00:00
parent 39b270225d
commit 5a10da129f
2 changed files with 20 additions and 19 deletions

View File

@ -11,6 +11,7 @@
#define LLD_READER_WRITER_PE_COFF_ATOMS_H
#include "lld/Core/File.h"
#include "lld/ReaderWriter/Simple.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/Object/COFF.h"
@ -296,6 +297,22 @@ private:
const DefinedAtom *_importTableEntry;
};
// An instance of this class represents "input file" for atoms created in a
// pass. Atoms need to be associated to an input file even if it's not read from
// a file, so we use this class for that.
class VirtualFile : public SimpleFile {
public:
VirtualFile(const LinkingContext &ctx)
: SimpleFile(ctx, "<virtual-file>"), _nextOrdinal(0) {
setOrdinal(ctx.getNextOrdinalAndIncrement());
}
uint64_t getNextOrdinal() { return _nextOrdinal++; }
private:
uint64_t _nextOrdinal;
};
//===----------------------------------------------------------------------===//
//
// Utility functions to handle layout edges.

View File

@ -43,14 +43,13 @@ namespace idata {
class DLLNameAtom;
class HintNameAtom;
class IdataPassFile;
class ImportTableEntryAtom;
// A state object of this pass.
struct Context {
Context(MutableFile &f, IdataPassFile &g) : file(f), dummyFile(g) {}
Context(MutableFile &f, coff::VirtualFile &g) : file(f), dummyFile(g) {}
MutableFile &file;
IdataPassFile &dummyFile;
coff::VirtualFile &dummyFile;
};
/// The root class of all idata atoms.
@ -141,21 +140,6 @@ public:
virtual StringRef customSectionName() const { return ".idata.d"; }
};
// An instance of this class represents "input file" for atoms created in this
// pass. Only one instance of this class is created as a field of IdataPass.
class IdataPassFile : public SimpleFile {
public:
IdataPassFile(const LinkingContext &ctx)
: SimpleFile(ctx, "<idata-pass-file>"), _nextOrdinal(0) {
setOrdinal(ctx.getNextOrdinalAndIncrement());
}
uint64_t getNextOrdinal() { return _nextOrdinal++; }
private:
uint64_t _nextOrdinal;
};
} // namespace idata
class IdataPass : public lld::Pass {
@ -173,7 +157,7 @@ private:
// A dummy file with which all the atoms created in the pass will be
// associated. Atoms need to be associated to an input file even if it's not
// read from a file, so we use this object.
idata::IdataPassFile _dummyFile;
coff::VirtualFile _dummyFile;
llvm::BumpPtrAllocator _alloc;
};