[LLD] Migrate llvm::make_unique to std::make_unique
Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368936
This commit is contained in:
parent
736259e342
commit
6ba7992031
|
@ -46,7 +46,7 @@ using namespace lld::coff;
|
|||
static std::unique_ptr<raw_fd_ostream> openFile(StringRef file) {
|
||||
std::error_code ec;
|
||||
auto ret =
|
||||
llvm::make_unique<raw_fd_ostream>(file, ec, sys::fs::OpenFlags::OF_None);
|
||||
std::make_unique<raw_fd_ostream>(file, ec, sys::fs::OpenFlags::OF_None);
|
||||
if (ec) {
|
||||
error("cannot open " + file + ": " + ec.message());
|
||||
return nullptr;
|
||||
|
@ -105,7 +105,7 @@ BitcodeCompiler::BitcodeCompiler() {
|
|||
backend = lto::createInProcessThinBackend(config->thinLTOJobs);
|
||||
}
|
||||
|
||||
ltoObj = llvm::make_unique<lto::LTO>(createConfig(), backend,
|
||||
ltoObj = std::make_unique<lto::LTO>(createConfig(), backend,
|
||||
config->ltoPartitions);
|
||||
}
|
||||
|
||||
|
@ -160,8 +160,8 @@ std::vector<StringRef> BitcodeCompiler::compile() {
|
|||
|
||||
checkError(ltoObj->run(
|
||||
[&](size_t task) {
|
||||
return llvm::make_unique<lto::NativeObjectStream>(
|
||||
llvm::make_unique<raw_svector_ostream>(buf[task]));
|
||||
return std::make_unique<lto::NativeObjectStream>(
|
||||
std::make_unique<raw_svector_ostream>(buf[task]));
|
||||
},
|
||||
cache));
|
||||
|
||||
|
|
|
@ -1150,7 +1150,7 @@ void DebugSHandler::finish() {
|
|||
// string table. Generally the string table subsection appears after the
|
||||
// checksum table, so we have to do this after looping over all the
|
||||
// subsections.
|
||||
auto newChecksums = make_unique<DebugChecksumsSubsection>(linker.pdbStrTab);
|
||||
auto newChecksums = std::make_unique<DebugChecksumsSubsection>(linker.pdbStrTab);
|
||||
for (FileChecksumEntry &fc : checksums) {
|
||||
SmallString<128> filename =
|
||||
exitOnErr(cVStrTab.getString(fc.FileNameOffset));
|
||||
|
|
|
@ -252,7 +252,7 @@ std::string InputFile::getSrcMsg(const Symbol &sym, InputSectionBase &sec,
|
|||
}
|
||||
|
||||
template <class ELFT> void ObjFile<ELFT>::initializeDwarf() {
|
||||
dwarf = llvm::make_unique<DWARFContext>(make_unique<LLDDwarfObj<ELFT>>(this));
|
||||
dwarf = std::make_unique<DWARFContext>(std::make_unique<LLDDwarfObj<ELFT>>(this));
|
||||
for (std::unique_ptr<DWARFUnit> &cu : dwarf->compile_units()) {
|
||||
auto report = [](Error err) {
|
||||
handleAllErrors(std::move(err),
|
||||
|
|
|
@ -50,7 +50,7 @@ using namespace lld::elf;
|
|||
static std::unique_ptr<raw_fd_ostream> openFile(StringRef file) {
|
||||
std::error_code ec;
|
||||
auto ret =
|
||||
llvm::make_unique<raw_fd_ostream>(file, ec, sys::fs::OpenFlags::OF_None);
|
||||
std::make_unique<raw_fd_ostream>(file, ec, sys::fs::OpenFlags::OF_None);
|
||||
if (ec) {
|
||||
error("cannot open " + file + ": " + ec.message());
|
||||
return nullptr;
|
||||
|
@ -141,7 +141,7 @@ BitcodeCompiler::BitcodeCompiler() {
|
|||
backend = lto::createInProcessThinBackend(config->thinLTOJobs);
|
||||
}
|
||||
|
||||
ltoObj = llvm::make_unique<lto::LTO>(createConfig(), backend,
|
||||
ltoObj = std::make_unique<lto::LTO>(createConfig(), backend,
|
||||
config->ltoPartitions);
|
||||
|
||||
// Initialize usedStartStop.
|
||||
|
@ -251,8 +251,8 @@ std::vector<InputFile *> BitcodeCompiler::compile() {
|
|||
if (!bitcodeFiles.empty())
|
||||
checkError(ltoObj->run(
|
||||
[&](size_t task) {
|
||||
return llvm::make_unique<lto::NativeObjectStream>(
|
||||
llvm::make_unique<raw_svector_ostream>(buf[task]));
|
||||
return std::make_unique<lto::NativeObjectStream>(
|
||||
std::make_unique<raw_svector_ostream>(buf[task]));
|
||||
},
|
||||
cache));
|
||||
|
||||
|
|
|
@ -460,7 +460,7 @@ void LinkerScript::processSectionCommands() {
|
|||
// This is needed as there are some cases where we cannot just
|
||||
// thread the current state through to a lambda function created by the
|
||||
// script parser.
|
||||
auto deleter = make_unique<AddressState>();
|
||||
auto deleter = std::make_unique<AddressState>();
|
||||
ctx = deleter.get();
|
||||
ctx->outSec = aether;
|
||||
|
||||
|
@ -1057,7 +1057,7 @@ static uint64_t getInitialDot() {
|
|||
void LinkerScript::assignAddresses() {
|
||||
dot = getInitialDot();
|
||||
|
||||
auto deleter = make_unique<AddressState>();
|
||||
auto deleter = std::make_unique<AddressState>();
|
||||
ctx = deleter.get();
|
||||
errorOnMissingSection = true;
|
||||
switchTo(aether);
|
||||
|
|
|
@ -2629,7 +2629,7 @@ template <class ELFT> GdbIndexSection *GdbIndexSection::create() {
|
|||
|
||||
parallelForEachN(0, sections.size(), [&](size_t i) {
|
||||
ObjFile<ELFT> *file = sections[i]->getFile<ELFT>();
|
||||
DWARFContext dwarf(make_unique<LLDDwarfObj<ELFT>>(file));
|
||||
DWARFContext dwarf(std::make_unique<LLDDwarfObj<ELFT>>(file));
|
||||
|
||||
chunks[i].sec = sections[i];
|
||||
chunks[i].compilationUnits = readCuList(dwarf);
|
||||
|
|
|
@ -101,7 +101,7 @@ public:
|
|||
auto file = std::unique_ptr<T>(new T(std::forward<Args>(args)...));
|
||||
auto *filePtr = file.get();
|
||||
auto *ctx = const_cast<MachOLinkingContext *>(this);
|
||||
ctx->getNodes().push_back(llvm::make_unique<FileNode>(std::move(file)));
|
||||
ctx->getNodes().push_back(std::make_unique<FileNode>(std::move(file)));
|
||||
return filePtr;
|
||||
}
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ public:
|
|||
static std::vector<std::unique_ptr<File>>
|
||||
makeErrorFile(StringRef path, std::error_code ec) {
|
||||
std::vector<std::unique_ptr<File>> result;
|
||||
result.push_back(llvm::make_unique<ErrorFile>(path, ec));
|
||||
result.push_back(std::make_unique<ErrorFile>(path, ec));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ static void addFile(StringRef path, MachOLinkingContext &ctx,
|
|||
std::vector<std::unique_ptr<File>> files =
|
||||
loadFile(ctx, path, loadWholeArchive, upwardDylib);
|
||||
for (std::unique_ptr<File> &file : files)
|
||||
ctx.getNodes().push_back(llvm::make_unique<FileNode>(std::move(file)));
|
||||
ctx.getNodes().push_back(std::make_unique<FileNode>(std::move(file)));
|
||||
}
|
||||
|
||||
// Export lists are one symbol per line. Blank lines are ignored.
|
||||
|
@ -1138,7 +1138,7 @@ static void createFiles(MachOLinkingContext &ctx, bool Implicit) {
|
|||
ctx.createInternalFiles(Files);
|
||||
for (auto i = Files.rbegin(), e = Files.rend(); i != e; ++i) {
|
||||
auto &members = ctx.getNodes();
|
||||
members.insert(members.begin(), llvm::make_unique<FileNode>(std::move(*i)));
|
||||
members.insert(members.begin(), std::make_unique<FileNode>(std::move(*i)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1185,7 +1185,7 @@ bool link(llvm::ArrayRef<const char *> args, bool CanExitEarly,
|
|||
merged = mergedFile.get();
|
||||
auto &members = ctx.getNodes();
|
||||
members.insert(members.begin(),
|
||||
llvm::make_unique<FileNode>(std::move(mergedFile)));
|
||||
std::make_unique<FileNode>(std::move(mergedFile)));
|
||||
}
|
||||
resolveTask.end();
|
||||
|
||||
|
|
|
@ -210,7 +210,7 @@ public:
|
|||
const Registry ®) const override {
|
||||
StringRef path = mb->getBufferIdentifier();
|
||||
std::unique_ptr<File> ret =
|
||||
llvm::make_unique<FileArchive>(std::move(mb), reg, path, _logLoading);
|
||||
std::make_unique<FileArchive>(std::move(mb), reg, path, _logLoading);
|
||||
return std::move(ret);
|
||||
}
|
||||
|
||||
|
|
|
@ -573,7 +573,7 @@ private:
|
|||
|
||||
void addCompactUnwindPass(PassManager &pm, const MachOLinkingContext &ctx) {
|
||||
assert(ctx.needsCompactUnwindPass());
|
||||
pm.add(llvm::make_unique<CompactUnwindPass>(ctx));
|
||||
pm.add(std::make_unique<CompactUnwindPass>(ctx));
|
||||
}
|
||||
|
||||
} // end namesapce mach_o
|
||||
|
|
|
@ -176,7 +176,7 @@ private:
|
|||
|
||||
void addGOTPass(PassManager &pm, const MachOLinkingContext &ctx) {
|
||||
assert(ctx.needsGOTPass());
|
||||
pm.add(llvm::make_unique<GOTPass>(ctx));
|
||||
pm.add(std::make_unique<GOTPass>(ctx));
|
||||
}
|
||||
|
||||
} // end namesapce mach_o
|
||||
|
|
|
@ -478,7 +478,7 @@ llvm::Error LayoutPass::perform(SimpleFile &mergedFile) {
|
|||
}
|
||||
|
||||
void addLayoutPass(PassManager &pm, const MachOLinkingContext &ctx) {
|
||||
pm.add(llvm::make_unique<LayoutPass>(
|
||||
pm.add(std::make_unique<LayoutPass>(
|
||||
ctx.registry(), [&](const DefinedAtom * left, const DefinedAtom * right,
|
||||
bool & leftBeforeRight) ->bool {
|
||||
return ctx.customAtomOrderer(left, right, leftBeforeRight);
|
||||
|
|
|
@ -802,9 +802,9 @@ void MachOLinkingContext::addSectCreateSection(
|
|||
std::unique_ptr<MemoryBuffer> content) {
|
||||
|
||||
if (!_sectCreateFile) {
|
||||
auto sectCreateFile = llvm::make_unique<mach_o::SectCreateFile>();
|
||||
auto sectCreateFile = std::make_unique<mach_o::SectCreateFile>();
|
||||
_sectCreateFile = sectCreateFile.get();
|
||||
getNodes().push_back(llvm::make_unique<FileNode>(std::move(sectCreateFile)));
|
||||
getNodes().push_back(std::make_unique<FileNode>(std::move(sectCreateFile)));
|
||||
}
|
||||
|
||||
assert(_sectCreateFile && "sectcreate file does not exist.");
|
||||
|
@ -1019,7 +1019,7 @@ void MachOLinkingContext::finalizeInputFiles() {
|
|||
return !isLibrary(a) && isLibrary(b);
|
||||
});
|
||||
size_t numLibs = std::count_if(elements.begin(), elements.end(), isLibrary);
|
||||
elements.push_back(llvm::make_unique<GroupEnd>(numLibs));
|
||||
elements.push_back(std::make_unique<GroupEnd>(numLibs));
|
||||
}
|
||||
|
||||
llvm::Error MachOLinkingContext::handleLoadedFile(File &file) {
|
||||
|
|
|
@ -542,7 +542,7 @@ public:
|
|||
loadFile(std::unique_ptr<MemoryBuffer> mb,
|
||||
const Registry ®istry) const override {
|
||||
std::unique_ptr<File> ret =
|
||||
llvm::make_unique<MachOFile>(std::move(mb), &_ctx);
|
||||
std::make_unique<MachOFile>(std::move(mb), &_ctx);
|
||||
return std::move(ret);
|
||||
}
|
||||
|
||||
|
@ -568,7 +568,7 @@ public:
|
|||
loadFile(std::unique_ptr<MemoryBuffer> mb,
|
||||
const Registry ®istry) const override {
|
||||
std::unique_ptr<File> ret =
|
||||
llvm::make_unique<MachODylibFile>(std::move(mb), &_ctx);
|
||||
std::make_unique<MachODylibFile>(std::move(mb), &_ctx);
|
||||
return std::move(ret);
|
||||
}
|
||||
|
||||
|
|
|
@ -717,7 +717,7 @@ llvm::Error parseStabs(MachOFile &file,
|
|||
// FIXME: Kill this off when we can move to sane yaml parsing.
|
||||
std::unique_ptr<BumpPtrAllocator> allocator;
|
||||
if (copyRefs)
|
||||
allocator = llvm::make_unique<BumpPtrAllocator>();
|
||||
allocator = std::make_unique<BumpPtrAllocator>();
|
||||
|
||||
enum { start, inBeginEnd } state = start;
|
||||
|
||||
|
@ -812,7 +812,7 @@ llvm::Error parseStabs(MachOFile &file,
|
|||
stabsList.push_back(stab);
|
||||
}
|
||||
|
||||
file.setDebugInfo(llvm::make_unique<StabsDebugInfo>(std::move(stabsList)));
|
||||
file.setDebugInfo(std::make_unique<StabsDebugInfo>(std::move(stabsList)));
|
||||
|
||||
// FIXME: Kill this off when we fix YAML memory ownership.
|
||||
file.debugInfo()->setAllocator(std::move(allocator));
|
||||
|
@ -974,11 +974,11 @@ llvm::Error parseDebugInfo(MachOFile &file,
|
|||
// memory ownership.
|
||||
std::unique_ptr<BumpPtrAllocator> allocator;
|
||||
if (copyRefs) {
|
||||
allocator = llvm::make_unique<BumpPtrAllocator>();
|
||||
allocator = std::make_unique<BumpPtrAllocator>();
|
||||
tuOrErr->name = copyDebugString(tuOrErr->name, *allocator);
|
||||
tuOrErr->path = copyDebugString(tuOrErr->path, *allocator);
|
||||
}
|
||||
file.setDebugInfo(llvm::make_unique<DwarfDebugInfo>(std::move(*tuOrErr)));
|
||||
file.setDebugInfo(std::make_unique<DwarfDebugInfo>(std::move(*tuOrErr)));
|
||||
if (copyRefs)
|
||||
file.debugInfo()->setAllocator(std::move(allocator));
|
||||
} else
|
||||
|
|
|
@ -124,7 +124,7 @@ private:
|
|||
|
||||
|
||||
void addObjCPass(PassManager &pm, const MachOLinkingContext &ctx) {
|
||||
pm.add(llvm::make_unique<ObjCPass>(ctx));
|
||||
pm.add(std::make_unique<ObjCPass>(ctx));
|
||||
}
|
||||
|
||||
} // end namespace mach_o
|
||||
|
|
|
@ -121,7 +121,7 @@ private:
|
|||
|
||||
|
||||
void addShimPass(PassManager &pm, const MachOLinkingContext &ctx) {
|
||||
pm.add(llvm::make_unique<ShimPass>(ctx));
|
||||
pm.add(std::make_unique<ShimPass>(ctx));
|
||||
}
|
||||
|
||||
} // end namespace mach_o
|
||||
|
|
|
@ -133,7 +133,7 @@ private:
|
|||
|
||||
void addTLVPass(PassManager &pm, const MachOLinkingContext &ctx) {
|
||||
assert(ctx.needsTLVPass());
|
||||
pm.add(llvm::make_unique<TLVPass>(ctx));
|
||||
pm.add(std::make_unique<TLVPass>(ctx));
|
||||
}
|
||||
|
||||
} // end namesapce mach_o
|
||||
|
|
|
@ -67,7 +67,7 @@ static std::unique_ptr<lto::LTO> createLTO() {
|
|||
lto::ThinBackend backend;
|
||||
if (config->thinLTOJobs != -1U)
|
||||
backend = lto::createInProcessThinBackend(config->thinLTOJobs);
|
||||
return llvm::make_unique<lto::LTO>(std::move(c), backend,
|
||||
return std::make_unique<lto::LTO>(std::move(c), backend,
|
||||
config->ltoPartitions);
|
||||
}
|
||||
|
||||
|
@ -137,8 +137,8 @@ std::vector<StringRef> BitcodeCompiler::compile() {
|
|||
|
||||
checkError(ltoObj->run(
|
||||
[&](size_t task) {
|
||||
return llvm::make_unique<lto::NativeObjectStream>(
|
||||
llvm::make_unique<raw_svector_ostream>(buf[task]));
|
||||
return std::make_unique<lto::NativeObjectStream>(
|
||||
std::make_unique<raw_svector_ostream>(buf[task]));
|
||||
},
|
||||
cache));
|
||||
|
||||
|
|
Loading…
Reference in New Issue