Move OffsetInArchive to BitcodeFile.

It is the only file type that needs it.

llvm-svn: 298323
This commit is contained in:
Rafael Espindola 2017-03-20 23:47:06 +00:00
parent 82a0c97b32
commit b57e496dfa
2 changed files with 11 additions and 11 deletions

View File

@ -767,7 +767,8 @@ static uint8_t getBitcodeMachineKind(MemoryBufferRef MB) {
} }
} }
BitcodeFile::BitcodeFile(MemoryBufferRef MB) : InputFile(BitcodeKind, MB) { BitcodeFile::BitcodeFile(MemoryBufferRef MB, uint64_t OffsetInArchive)
: InputFile(BitcodeKind, MB), OffsetInArchive(OffsetInArchive) {
EKind = getBitcodeELFKind(MB); EKind = getBitcodeELFKind(MB);
EMachine = getBitcodeMachineKind(MB); EMachine = getBitcodeMachineKind(MB);
} }
@ -905,10 +906,9 @@ static bool isBitcode(MemoryBufferRef MB) {
InputFile *elf::createObjectFile(MemoryBufferRef MB, StringRef ArchiveName, InputFile *elf::createObjectFile(MemoryBufferRef MB, StringRef ArchiveName,
uint64_t OffsetInArchive) { uint64_t OffsetInArchive) {
InputFile *F = InputFile *F = isBitcode(MB) ? make<BitcodeFile>(MB, OffsetInArchive)
isBitcode(MB) ? make<BitcodeFile>(MB) : createELFFile<ObjectFile>(MB); : createELFFile<ObjectFile>(MB);
F->ArchiveName = ArchiveName; F->ArchiveName = ArchiveName;
F->OffsetInArchive = OffsetInArchive;
return F; return F;
} }

View File

@ -79,12 +79,6 @@ public:
// string for creating error messages. // string for creating error messages.
StringRef ArchiveName; StringRef ArchiveName;
// If this file is in an archive, the member contains the offset of
// the file in the archive. Otherwise, it's just zero. We store this
// field so that we can pass it to lib/LTO in order to disambiguate
// between objects.
uint64_t OffsetInArchive;
// If this is an architecture-specific file, the following members // If this is an architecture-specific file, the following members
// have ELF type (i.e. ELF{32,64}{LE,BE}) and target machine type. // have ELF type (i.e. ELF{32,64}{LE,BE}) and target machine type.
ELFKind EKind = ELFNoneKind; ELFKind EKind = ELFNoneKind;
@ -255,13 +249,19 @@ private:
class BitcodeFile : public InputFile { class BitcodeFile : public InputFile {
public: public:
explicit BitcodeFile(MemoryBufferRef M); BitcodeFile(MemoryBufferRef M, uint64_t OffsetInArchive);
static bool classof(const InputFile *F) { return F->kind() == BitcodeKind; } static bool classof(const InputFile *F) { return F->kind() == BitcodeKind; }
template <class ELFT> template <class ELFT>
void parse(llvm::DenseSet<llvm::CachedHashStringRef> &ComdatGroups); void parse(llvm::DenseSet<llvm::CachedHashStringRef> &ComdatGroups);
ArrayRef<Symbol *> getSymbols() { return Symbols; } ArrayRef<Symbol *> getSymbols() { return Symbols; }
std::unique_ptr<llvm::lto::InputFile> Obj; std::unique_ptr<llvm::lto::InputFile> Obj;
// If this file is in an archive, the member contains the offset of
// the file in the archive. Otherwise, it's just zero. We store this
// field so that we can pass it to lib/LTO in order to disambiguate
// between objects.
uint64_t OffsetInArchive;
private: private:
std::vector<Symbol *> Symbols; std::vector<Symbol *> Symbols;
}; };