From dbf37e956a0dd60ac84e3c08bc1fe8170cf44d22 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sat, 16 Nov 2024 23:50:34 -0800 Subject: [ELF] Move InputFile storage from make<> to LinkerDriver::files --- lld/ELF/InputFiles.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'lld/ELF/InputFiles.cpp') diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 224912706f20..3a0ae43b813f 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -216,6 +216,8 @@ InputFile::InputFile(Ctx &ctx, Kind k, MemoryBufferRef m) ++ctx.driver.nextGroupId; } +InputFile::~InputFile() {} + std::optional elf::readFile(Ctx &ctx, StringRef path) { llvm::TimeTraceScope timeScope("Load input files", path); @@ -345,19 +347,22 @@ extern template void ObjFile::importCmseSymbols(); extern template void ObjFile::importCmseSymbols(); template -static void doParseFiles(Ctx &ctx, const std::vector &files) { +static void +doParseFiles(Ctx &ctx, + const SmallVector, 0> &files) { // Add all files to the symbol table. This will add almost all symbols that we // need to the symbol table. This process might add files to the link due to // addDependentLibrary. for (size_t i = 0; i < files.size(); ++i) { llvm::TimeTraceScope timeScope("Parse input files", files[i]->getName()); - doParseFile(ctx, files[i]); + doParseFile(ctx, files[i].get()); } if (ctx.driver.armCmseImpLib) cast>(*ctx.driver.armCmseImpLib).importCmseSymbols(); } -void elf::parseFiles(Ctx &ctx, const std::vector &files) { +void elf::parseFiles(Ctx &ctx, + const SmallVector, 0> &files) { llvm::TimeTraceScope timeScope("Parse input files"); invokeELFT(doParseFiles, ctx, files); } @@ -1878,21 +1883,22 @@ InputFile *elf::createInternalFile(Ctx &ctx, StringRef name) { return file; } -ELFFileBase *elf::createObjFile(Ctx &ctx, MemoryBufferRef mb, - StringRef archiveName, bool lazy) { - ELFFileBase *f; +std::unique_ptr elf::createObjFile(Ctx &ctx, MemoryBufferRef mb, + StringRef archiveName, + bool lazy) { + std::unique_ptr f; switch (getELFKind(ctx, mb, archiveName)) { case ELF32LEKind: - f = make>(ctx, ELF32LEKind, mb, archiveName); + f = std::make_unique>(ctx, ELF32LEKind, mb, archiveName); break; case ELF32BEKind: - f = make>(ctx, ELF32BEKind, mb, archiveName); + f = std::make_unique>(ctx, ELF32BEKind, mb, archiveName); break; case ELF64LEKind: - f = make>(ctx, ELF64LEKind, mb, archiveName); + f = std::make_unique>(ctx, ELF64LEKind, mb, archiveName); break; case ELF64BEKind: - f = make>(ctx, ELF64BEKind, mb, archiveName); + f = std::make_unique>(ctx, ELF64BEKind, mb, archiveName); break; default: llvm_unreachable("getELFKind"); -- cgit v1.2.3