[lld] r257830 - Add File::kind's for all subclasses of File.
Pete Cooper via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 14 14:55:50 PST 2016
Author: pete
Date: Thu Jan 14 16:55:38 2016
New Revision: 257830
URL: http://llvm.org/viewvc/llvm-project?rev=257830&view=rev
Log:
Add File::kind's for all subclasses of File.
This is to enable isa<> support for any files which need it.
It will be used in an upcoming patch to differentiate MachOFile from other implicitly generated files.
Reviewed by Lang Hames.
Differential Revision: http://reviews.llvm.org/D16103
Modified:
lld/trunk/include/lld/Core/File.h
lld/trunk/include/lld/Core/Resolver.h
lld/trunk/include/lld/Core/Simple.h
lld/trunk/lib/Core/LinkingContext.cpp
lld/trunk/lib/Core/Resolver.cpp
lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64DynamicLibraryWriter.h
lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64ExecutableWriter.cpp
lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp
lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp
lld/trunk/lib/ReaderWriter/ELF/ELFFile.cpp
lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp
lld/trunk/lib/ReaderWriter/ELF/X86/X86DynamicLibraryWriter.h
lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64DynamicLibraryWriter.h
lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64ExecutableWriter.h
lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp
lld/trunk/lib/ReaderWriter/MachO/ExecutableAtoms.h
lld/trunk/lib/ReaderWriter/MachO/File.h
lld/trunk/lib/ReaderWriter/MachO/SectCreateFile.h
lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
Modified: lld/trunk/include/lld/Core/File.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/File.h?rev=257830&r1=257829&r2=257830&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/File.h (original)
+++ lld/trunk/include/lld/Core/File.h Thu Jan 14 16:55:38 2016
@@ -45,9 +45,19 @@ public:
/// \brief Kinds of files that are supported.
enum Kind {
- kindObject, ///< object file (.o)
- kindSharedLibrary, ///< shared library (.so)
- kindArchiveLibrary ///< archive (.a)
+ kindErrorObject, ///< a error object file (.o)
+ kindNormalizedObject, ///< a normalized file (.o)
+ kindMachObject, ///< a MachO object file (.o)
+ kindELFObject, ///< a ELF object file (.o)
+ kindCEntryObject, ///< a file for CEntries
+ kindEntryObject, ///< a file for the entry
+ kindUndefinedSymsObject, ///< a file for undefined symbols
+ kindAliasSymsObject, ///< a file for alias symbols
+ kindStubHelperObject, ///< a file for stub helpers
+ kindResolverMergedObject, ///< the resolver merged file.
+ kindSectCreateObject, ///< a sect create object file (.o)
+ kindSharedLibrary, ///< shared library (.so)
+ kindArchiveLibrary ///< archive (.a)
};
/// \brief Returns file kind. Need for dyn_cast<> on File objects.
@@ -190,7 +200,7 @@ private:
class ErrorFile : public File {
public:
ErrorFile(StringRef path, std::error_code ec)
- : File(path, kindObject), _ec(ec) {}
+ : File(path, kindErrorObject), _ec(ec) {}
std::error_code doParse() override { return _ec; }
Modified: lld/trunk/include/lld/Core/Resolver.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Resolver.h?rev=257830&r1=257829&r2=257830&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Resolver.h (original)
+++ lld/trunk/include/lld/Core/Resolver.h Thu Jan 14 16:55:38 2016
@@ -83,7 +83,7 @@ private:
class MergedFile : public SimpleFile {
public:
- MergedFile() : SimpleFile("<linker-internal>") {}
+ MergedFile() : SimpleFile("<linker-internal>", kindResolverMergedObject) {}
void addAtoms(std::vector<const Atom*>& atoms);
};
Modified: lld/trunk/include/lld/Core/Simple.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Simple.h?rev=257830&r1=257829&r2=257830&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Simple.h (original)
+++ lld/trunk/include/lld/Core/Simple.h Thu Jan 14 16:55:38 2016
@@ -29,7 +29,8 @@ namespace lld {
class SimpleFile : public File {
public:
- SimpleFile(StringRef path) : File(path, kindObject) {}
+ SimpleFile(StringRef path, File::Kind kind)
+ : File(path, kind) {}
void addAtom(const DefinedAtom &a) { _defined.push_back(&a); }
void addAtom(const UndefinedAtom &a) { _undefined.push_back(&a); }
Modified: lld/trunk/lib/Core/LinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/LinkingContext.cpp?rev=257830&r1=257829&r2=257830&view=diff
==============================================================================
--- lld/trunk/lib/Core/LinkingContext.cpp (original)
+++ lld/trunk/lib/Core/LinkingContext.cpp Thu Jan 14 16:55:38 2016
@@ -50,7 +50,8 @@ std::unique_ptr<File>
LinkingContext::createEntrySymbolFile(StringRef filename) const {
if (entrySymbolName().empty())
return nullptr;
- std::unique_ptr<SimpleFile> entryFile(new SimpleFile(filename));
+ std::unique_ptr<SimpleFile> entryFile(new SimpleFile(filename,
+ File::kindEntryObject));
entryFile->addAtom(
*(new (_allocator) SimpleUndefinedAtom(*entryFile, entrySymbolName())));
return std::move(entryFile);
@@ -64,7 +65,8 @@ std::unique_ptr<File>
LinkingContext::createUndefinedSymbolFile(StringRef filename) const {
if (_initialUndefinedSymbols.empty())
return nullptr;
- std::unique_ptr<SimpleFile> undefinedSymFile(new SimpleFile(filename));
+ std::unique_ptr<SimpleFile> undefinedSymFile(
+ new SimpleFile(filename, File::kindUndefinedSymsObject));
for (StringRef undefSym : _initialUndefinedSymbols)
undefinedSymFile->addAtom(*(new (_allocator) SimpleUndefinedAtom(
*undefinedSymFile, undefSym)));
@@ -74,7 +76,8 @@ LinkingContext::createUndefinedSymbolFil
std::unique_ptr<File> LinkingContext::createAliasSymbolFile() const {
if (getAliases().empty())
return nullptr;
- std::unique_ptr<SimpleFile> file(new SimpleFile("<alias>"));
+ std::unique_ptr<SimpleFile> file(
+ new SimpleFile("<alias>", File::kindUndefinedSymsObject));
for (const auto &i : getAliases()) {
StringRef from = i.first;
StringRef to = i.second;
Modified: lld/trunk/lib/Core/Resolver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Resolver.cpp?rev=257830&r1=257829&r2=257830&view=diff
==============================================================================
--- lld/trunk/lib/Core/Resolver.cpp (original)
+++ lld/trunk/lib/Core/Resolver.cpp Thu Jan 14 16:55:38 2016
@@ -338,7 +338,17 @@ bool Resolver::resolveUndefines() {
file->beforeLink();
updatePreloadArchiveMap();
switch (file->kind()) {
- case File::kindObject: {
+ case File::kindErrorObject:
+ case File::kindNormalizedObject:
+ case File::kindMachObject:
+ case File::kindELFObject:
+ case File::kindCEntryObject:
+ case File::kindEntryObject:
+ case File::kindUndefinedSymsObject:
+ case File::kindAliasSymsObject:
+ case File::kindStubHelperObject:
+ case File::kindResolverMergedObject:
+ case File::kindSectCreateObject: {
// The same file may be visited more than once if the file is
// in --start-group and --end-group. Only library files should
// be processed more than once.
Modified: lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64DynamicLibraryWriter.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64DynamicLibraryWriter.h?rev=257830&r1=257829&r2=257830&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64DynamicLibraryWriter.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64DynamicLibraryWriter.h Thu Jan 14 16:55:38 2016
@@ -33,7 +33,7 @@ AArch64DynamicLibraryWriter::AArch64Dyna
void AArch64DynamicLibraryWriter::createImplicitFiles(
std::vector<std::unique_ptr<File>> &result) {
DynamicLibraryWriter::createImplicitFiles(result);
- auto gotFile = llvm::make_unique<SimpleFile>("GOTFile");
+ auto gotFile = llvm::make_unique<SimpleFile>("GOTFile", File::kindELFObject);
gotFile->addAtom(*new (gotFile->allocator()) GlobalOffsetTableAtom(*gotFile));
gotFile->addAtom(*new (gotFile->allocator()) DynamicAtom(*gotFile));
result.push_back(std::move(gotFile));
Modified: lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64ExecutableWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64ExecutableWriter.cpp?rev=257830&r1=257829&r2=257830&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64ExecutableWriter.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64ExecutableWriter.cpp Thu Jan 14 16:55:38 2016
@@ -22,7 +22,7 @@ AArch64ExecutableWriter::AArch64Executab
void AArch64ExecutableWriter::createImplicitFiles(
std::vector<std::unique_ptr<File>> &result) {
ExecutableWriter::createImplicitFiles(result);
- auto gotFile = llvm::make_unique<SimpleFile>("GOTFile");
+ auto gotFile = llvm::make_unique<SimpleFile>("GOTFile", File::kindELFObject);
gotFile->addAtom(*new (gotFile->allocator()) GlobalOffsetTableAtom(*gotFile));
if (this->_ctx.isDynamic())
gotFile->addAtom(*new (gotFile->allocator()) DynamicAtom(*gotFile));
Modified: lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp?rev=257830&r1=257829&r2=257830&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp Thu Jan 14 16:55:38 2016
@@ -129,7 +129,8 @@ public:
class ELFPassFile : public SimpleFile {
public:
- ELFPassFile(const ELFLinkingContext &eti) : SimpleFile("ELFPassFile") {
+ ELFPassFile(const ELFLinkingContext &eti)
+ : SimpleFile("ELFPassFile", kindELFObject) {
setOrdinal(eti.getNextOrdinalAndIncrement());
}
Modified: lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp?rev=257830&r1=257829&r2=257830&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp Thu Jan 14 16:55:38 2016
@@ -314,7 +314,8 @@ public:
class ELFPassFile : public SimpleFile {
public:
- ELFPassFile(const ELFLinkingContext &eti) : SimpleFile("ELFPassFile") {
+ ELFPassFile(const ELFLinkingContext &eti)
+ : SimpleFile("ELFPassFile", kindELFObject) {
setOrdinal(eti.getNextOrdinalAndIncrement());
}
Modified: lld/trunk/lib/ReaderWriter/ELF/ELFFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFFile.cpp?rev=257830&r1=257829&r2=257830&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFFile.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFFile.cpp Thu Jan 14 16:55:38 2016
@@ -16,14 +16,15 @@ namespace elf {
template <typename ELFT>
ELFFile<ELFT>::ELFFile(StringRef name, ELFLinkingContext &ctx)
- : SimpleFile(name), _ordinal(0), _doStringsMerge(ctx.mergeCommonStrings()),
- _useWrap(false), _ctx(ctx) {
+ : SimpleFile(name, kindELFObject), _ordinal(0),
+ _doStringsMerge(ctx.mergeCommonStrings()), _useWrap(false), _ctx(ctx) {
setLastError(std::error_code());
}
template <typename ELFT>
ELFFile<ELFT>::ELFFile(std::unique_ptr<MemoryBuffer> mb, ELFLinkingContext &ctx)
- : SimpleFile(mb->getBufferIdentifier()), _mb(std::move(mb)), _ordinal(0),
+ : SimpleFile(mb->getBufferIdentifier(), kindELFObject),
+ _mb(std::move(mb)), _ordinal(0),
_doStringsMerge(ctx.mergeCommonStrings()),
_useWrap(ctx.wrapCalls().size()), _ctx(ctx) {}
Modified: lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp?rev=257830&r1=257829&r2=257830&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp Thu Jan 14 16:55:38 2016
@@ -170,7 +170,7 @@ ErrorOr<StringRef> ELFLinkingContext::se
void ELFLinkingContext::createInternalFiles(
std::vector<std::unique_ptr<File>> &files) const {
std::unique_ptr<SimpleFile> file(
- new SimpleFile("<internal file for --defsym>"));
+ new SimpleFile("<internal file for --defsym>", File::kindELFObject));
for (auto &i : getAbsoluteSymbols()) {
StringRef sym = i.first;
uint64_t val = i.second;
@@ -191,7 +191,7 @@ std::unique_ptr<File> ELFLinkingContext:
if (_initialUndefinedSymbols.empty())
return nullptr;
std::unique_ptr<SimpleFile> undefinedSymFile(
- new SimpleFile("command line option -u"));
+ new SimpleFile("command line option -u", File::kindELFObject));
for (auto undefSymStr : _initialUndefinedSymbols)
undefinedSymFile->addAtom(*(new (_allocator) CommandLineUndefinedAtom(
*undefinedSymFile, undefSymStr)));
Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp?rev=257830&r1=257829&r2=257830&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp Thu Jan 14 16:55:38 2016
@@ -117,7 +117,8 @@ public:
class ELFPassFile : public SimpleFile {
public:
- ELFPassFile(const ELFLinkingContext &eti) : SimpleFile("ELFPassFile") {
+ ELFPassFile(const ELFLinkingContext &eti)
+ : SimpleFile("ELFPassFile", kindELFObject) {
setOrdinal(eti.getNextOrdinalAndIncrement());
}
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp?rev=257830&r1=257829&r2=257830&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp Thu Jan 14 16:55:38 2016
@@ -492,7 +492,7 @@ public:
class RelocationPassFile : public SimpleFile {
public:
RelocationPassFile(const ELFLinkingContext &ctx)
- : SimpleFile("RelocationPassFile") {
+ : SimpleFile("RelocationPassFile", kindELFObject) {
setOrdinal(ctx.getNextOrdinalAndIncrement());
}
Modified: lld/trunk/lib/ReaderWriter/ELF/X86/X86DynamicLibraryWriter.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86/X86DynamicLibraryWriter.h?rev=257830&r1=257829&r2=257830&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86/X86DynamicLibraryWriter.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86/X86DynamicLibraryWriter.h Thu Jan 14 16:55:38 2016
@@ -32,7 +32,7 @@ X86DynamicLibraryWriter::X86DynamicLibra
void X86DynamicLibraryWriter::createImplicitFiles(
std::vector<std::unique_ptr<File>> &result) {
DynamicLibraryWriter::createImplicitFiles(result);
- auto gotFile = llvm::make_unique<SimpleFile>("GOTFile");
+ auto gotFile = llvm::make_unique<SimpleFile>("GOTFile", File::kindELFObject);
gotFile->addAtom(*new (gotFile->allocator()) GlobalOffsetTableAtom(*gotFile));
gotFile->addAtom(*new (gotFile->allocator()) DynamicAtom(*gotFile));
result.push_back(std::move(gotFile));
Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64DynamicLibraryWriter.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64DynamicLibraryWriter.h?rev=257830&r1=257829&r2=257830&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64DynamicLibraryWriter.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64DynamicLibraryWriter.h Thu Jan 14 16:55:38 2016
@@ -33,7 +33,7 @@ X86_64DynamicLibraryWriter::X86_64Dynami
void X86_64DynamicLibraryWriter::createImplicitFiles(
std::vector<std::unique_ptr<File>> &result) {
DynamicLibraryWriter::createImplicitFiles(result);
- auto gotFile = llvm::make_unique<SimpleFile>("GOTFile");
+ auto gotFile = llvm::make_unique<SimpleFile>("GOTFile", File::kindELFObject);
gotFile->addAtom(*new (gotFile->allocator()) GlobalOffsetTableAtom(*gotFile));
gotFile->addAtom(*new (gotFile->allocator()) DynamicAtom(*gotFile));
result.push_back(std::move(gotFile));
Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64ExecutableWriter.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64ExecutableWriter.h?rev=257830&r1=257829&r2=257830&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64ExecutableWriter.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64ExecutableWriter.h Thu Jan 14 16:55:38 2016
@@ -25,7 +25,8 @@ protected:
void
createImplicitFiles(std::vector<std::unique_ptr<File>> &result) override {
ExecutableWriter::createImplicitFiles(result);
- auto gotFile = llvm::make_unique<SimpleFile>("GOTFile");
+ auto gotFile = llvm::make_unique<SimpleFile>("GOTFile",
+ File::kindELFObject);
gotFile->addAtom(*new (gotFile->allocator())
GlobalOffsetTableAtom(*gotFile));
if (this->_ctx.isDynamic())
Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp?rev=257830&r1=257829&r2=257830&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp Thu Jan 14 16:55:38 2016
@@ -93,7 +93,8 @@ public:
class ELFPassFile : public SimpleFile {
public:
- ELFPassFile(const ELFLinkingContext &eti) : SimpleFile("ELFPassFile") {
+ ELFPassFile(const ELFLinkingContext &eti)
+ : SimpleFile("ELFPassFile", kindELFObject) {
setOrdinal(eti.getNextOrdinalAndIncrement());
}
Modified: lld/trunk/lib/ReaderWriter/MachO/ExecutableAtoms.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ExecutableAtoms.h?rev=257830&r1=257829&r2=257830&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ExecutableAtoms.h (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ExecutableAtoms.h Thu Jan 14 16:55:38 2016
@@ -34,7 +34,7 @@ namespace mach_o {
class CEntryFile : public SimpleFile {
public:
CEntryFile(const MachOLinkingContext &context)
- : SimpleFile("C entry"),
+ : SimpleFile("C entry", kindCEntryObject),
_undefMain(*this, context.entrySymbolName()) {
this->addAtom(_undefMain);
}
@@ -51,7 +51,7 @@ private:
class StubHelperFile : public SimpleFile {
public:
StubHelperFile(const MachOLinkingContext &context)
- : SimpleFile("stub runtime"),
+ : SimpleFile("stub runtime", kindStubHelperObject),
_undefBinder(*this, context.binderSymbolName()) {
this->addAtom(_undefBinder);
}
Modified: lld/trunk/lib/ReaderWriter/MachO/File.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/File.h?rev=257830&r1=257829&r2=257830&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/File.h (original)
+++ lld/trunk/lib/ReaderWriter/MachO/File.h Thu Jan 14 16:55:38 2016
@@ -25,9 +25,10 @@ using lld::mach_o::normalized::Section;
class MachOFile : public SimpleFile {
public:
MachOFile(std::unique_ptr<MemoryBuffer> mb, MachOLinkingContext *ctx)
- : SimpleFile(mb->getBufferIdentifier()), _mb(std::move(mb)), _ctx(ctx) {}
+ : SimpleFile(mb->getBufferIdentifier(), File::kindMachObject),
+ _mb(std::move(mb)), _ctx(ctx) {}
- MachOFile(StringRef path) : SimpleFile(path) {}
+ MachOFile(StringRef path) : SimpleFile(path, File::kindMachObject) {}
void addDefinedAtom(StringRef name, Atom::Scope scope,
DefinedAtom::ContentType type, DefinedAtom::Merge merge,
@@ -187,6 +188,11 @@ public:
visitor(offAndAtom.atom, offAndAtom.offset);
}
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const File *F) {
+ return F->kind() == File::kindMachObject;
+ }
+
protected:
std::error_code doParse() override {
// Convert binary file to normalized mach-o.
Modified: lld/trunk/lib/ReaderWriter/MachO/SectCreateFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/SectCreateFile.h?rev=257830&r1=257829&r2=257830&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/SectCreateFile.h (original)
+++ lld/trunk/lib/ReaderWriter/MachO/SectCreateFile.h Thu Jan 14 16:55:38 2016
@@ -59,7 +59,7 @@ public:
std::unique_ptr<MemoryBuffer> _content;
};
- SectCreateFile() : File("sectcreate", kindObject) {}
+ SectCreateFile() : File("sectcreate", kindSectCreateObject) {}
void addSection(StringRef seg, StringRef sect,
std::unique_ptr<MemoryBuffer> content) {
Modified: lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp?rev=257830&r1=257829&r2=257830&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp (original)
+++ lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp Thu Jan 14 16:55:38 2016
@@ -294,7 +294,8 @@ template <> struct ScalarTraits<RefKind>
template <> struct ScalarEnumerationTraits<lld::File::Kind> {
static void enumeration(IO &io, lld::File::Kind &value) {
- io.enumCase(value, "object", lld::File::kindObject);
+ io.enumCase(value, "error-object", lld::File::kindErrorObject);
+ io.enumCase(value, "object", lld::File::kindMachObject);
io.enumCase(value, "shared-library", lld::File::kindSharedLibrary);
io.enumCase(value, "static-library", lld::File::kindArchiveLibrary);
}
@@ -630,9 +631,10 @@ template <> struct MappingTraits<const l
class NormalizedFile : public lld::File {
public:
- NormalizedFile(IO &io) : File("", kindObject), _io(io), _rnb(nullptr) {}
+ NormalizedFile(IO &io)
+ : File("", kindNormalizedObject), _io(io), _rnb(nullptr) {}
NormalizedFile(IO &io, const lld::File *file)
- : File(file->path(), kindObject), _io(io),
+ : File(file->path(), kindNormalizedObject), _io(io),
_rnb(new RefNameBuilder(*file)), _path(file->path()) {
for (const lld::DefinedAtom *a : file->defined())
_definedAtoms._atoms.push_back(a);
More information about the llvm-commits
mailing list