mirror of
https://github.com/intel/llvm.git
synced 2026-01-25 10:55:58 +08:00
Simplify memory management.
We no longer need an explicit delete or a polymorphic destructor. llvm-svn: 256333
This commit is contained in:
@@ -31,8 +31,6 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
InputFile::~InputFile() {}
|
||||
|
||||
template <class ELFT>
|
||||
ELFFileBase<ELFT>::ELFFileBase(Kind K, MemoryBufferRef M)
|
||||
: InputFile(K, M), ELFObj(MB.getBuffer(), ECRAII().getEC()) {}
|
||||
|
||||
@@ -35,7 +35,6 @@ class InputFile {
|
||||
public:
|
||||
enum Kind { ObjectKind, SharedKind, ArchiveKind };
|
||||
Kind kind() const { return FileKind; }
|
||||
virtual ~InputFile();
|
||||
|
||||
StringRef getName() const { return MB.getBufferIdentifier(); }
|
||||
|
||||
|
||||
@@ -44,12 +44,12 @@ static void checkCompatibility(InputFile *FileP) {
|
||||
|
||||
template <class ELFT>
|
||||
void SymbolTable<ELFT>::addFile(std::unique_ptr<InputFile> File) {
|
||||
InputFile *FileP = File.release();
|
||||
InputFile *FileP = File.get();
|
||||
checkCompatibility<ELFT>(FileP);
|
||||
|
||||
// .a file
|
||||
if (auto *F = dyn_cast<ArchiveFile>(FileP)) {
|
||||
ArchiveFiles.emplace_back(F);
|
||||
ArchiveFiles.emplace_back(cast<ArchiveFile>(File.release()));
|
||||
F->parse();
|
||||
for (Lazy &Sym : F->getLazySymbols())
|
||||
addLazy(&Sym);
|
||||
@@ -60,12 +60,10 @@ void SymbolTable<ELFT>::addFile(std::unique_ptr<InputFile> File) {
|
||||
if (auto *F = dyn_cast<SharedFile<ELFT>>(FileP)) {
|
||||
// DSOs are uniquified not by filename but by soname.
|
||||
F->parseSoName();
|
||||
if (!IncludedSoNames.insert(F->getSoName()).second) {
|
||||
delete FileP;
|
||||
if (!IncludedSoNames.insert(F->getSoName()).second)
|
||||
return;
|
||||
}
|
||||
|
||||
SharedFiles.emplace_back(F);
|
||||
SharedFiles.emplace_back(cast<SharedFile<ELFT>>(File.release()));
|
||||
F->parse();
|
||||
for (SharedSymbol<ELFT> &B : F->getSharedSymbols())
|
||||
resolve(&B);
|
||||
@@ -74,7 +72,7 @@ void SymbolTable<ELFT>::addFile(std::unique_ptr<InputFile> File) {
|
||||
|
||||
// .o file
|
||||
auto *F = cast<ObjectFile<ELFT>>(FileP);
|
||||
ObjectFiles.emplace_back(F);
|
||||
ObjectFiles.emplace_back(cast<ObjectFile<ELFT>>(File.release()));
|
||||
F->parse(Comdats);
|
||||
for (SymbolBody *B : F->getSymbols())
|
||||
resolve(B);
|
||||
|
||||
@@ -66,7 +66,7 @@ private:
|
||||
void resolve(SymbolBody *Body);
|
||||
std::string conflictMsg(SymbolBody *Old, SymbolBody *New);
|
||||
|
||||
std::vector<std::unique_ptr<InputFile>> ArchiveFiles;
|
||||
std::vector<std::unique_ptr<ArchiveFile>> ArchiveFiles;
|
||||
|
||||
// The order the global symbols are in is not defined. We can use an arbitrary
|
||||
// order, but it has to be reproducible. That is true even when cross linking.
|
||||
|
||||
Reference in New Issue
Block a user