Use make_unique.

llvm-svn: 228453
This commit is contained in:
Rui Ueyama 2015-02-06 22:44:16 +00:00
parent 3d982214b0
commit 92634be399
13 changed files with 28 additions and 31 deletions

View File

@ -122,8 +122,8 @@ bool Driver::link(LinkingContext &context, raw_ostream &diagnostics) {
llvm::sys::Process::GetEnv("LLD_RUN_ROUNDTRIP_TEST");
if (env.hasValue() && !env.getValue().empty()) {
pm.add(std::unique_ptr<Pass>(new RoundTripYAMLPass(context)));
pm.add(std::unique_ptr<Pass>(new RoundTripNativePass(context)));
pm.add(llvm::make_unique<RoundTripYAMLPass>(context));
pm.add(llvm::make_unique<RoundTripNativePass>(context));
}
#endif

View File

@ -518,13 +518,12 @@ lld::elf::createAArch64RelocationPass(const AArch64LinkingContext &ctx) {
switch (ctx.getOutputELFType()) {
case llvm::ELF::ET_EXEC:
if (ctx.isDynamic())
return std::unique_ptr<Pass>(new AArch64DynamicRelocationPass(ctx));
else
return std::unique_ptr<Pass>(new AArch64StaticRelocationPass(ctx));
return llvm::make_unique<AArch64DynamicRelocationPass>(ctx);
return llvm::make_unique<AArch64StaticRelocationPass>(ctx);
case llvm::ELF::ET_DYN:
return std::unique_ptr<Pass>(new AArch64DynamicRelocationPass(ctx));
return llvm::make_unique<AArch64DynamicRelocationPass>(ctx);
case llvm::ELF::ET_REL:
return std::unique_ptr<Pass>();
return nullptr;
default:
llvm_unreachable("Unhandled output file type");
}

View File

@ -128,8 +128,7 @@ lld::elf::createARMRelocationPass(const ARMLinkingContext &ctx) {
case llvm::ELF::ET_EXEC:
if (ctx.isDynamic())
llvm_unreachable("Unhandled output file type");
else
return std::unique_ptr<Pass>(new ARMStaticRelocationPass(ctx));
return llvm::make_unique<ARMStaticRelocationPass>(ctx);
default:
llvm_unreachable("Unhandled output file type");
}

View File

@ -65,7 +65,7 @@ ELFLinkingContext::ELFLinkingContext(
_finiFunction("_fini"), _sysrootPath("") {}
void ELFLinkingContext::addPasses(PassManager &pm) {
pm.add(std::unique_ptr<Pass>(new elf::OrderPass()));
pm.add(llvm::make_unique<elf::OrderPass>());
}
uint16_t ELFLinkingContext::getOutputMachine() const {

View File

@ -319,7 +319,7 @@ public:
void elf::HexagonLinkingContext::addPasses(PassManager &pm) {
if (isDynamic())
pm.add(std::unique_ptr<Pass>(new DynamicGOTPLTPass(*this)));
pm.add(llvm::make_unique<DynamicGOTPLTPass>(*this));
ELFLinkingContext::addPasses(pm);
}

View File

@ -71,7 +71,7 @@ void MipsLinkingContext::addPasses(PassManager &pm) {
if (pass)
pm.add(std::move(pass));
ELFLinkingContext::addPasses(pm);
pm.add(std::unique_ptr<Pass>(new elf::MipsCtorsOrderPass()));
pm.add(llvm::make_unique<elf::MipsCtorsOrderPass>());
}
bool MipsLinkingContext::isDynamicRelocation(const DefinedAtom &,

View File

@ -949,9 +949,9 @@ RelocationPass<ELFT>::getObjectEntry(const SharedLibraryAtom *a) {
static std::unique_ptr<Pass> createPass(MipsLinkingContext &ctx) {
switch (ctx.getTriple().getArch()) {
case llvm::Triple::mipsel:
return std::unique_ptr<Pass>(new RelocationPass<Mips32ELType>(ctx));
return llvm::make_unique<RelocationPass<Mips32ELType>>(ctx);
case llvm::Triple::mips64el:
return std::unique_ptr<Pass>(new RelocationPass<Mips64ELType>(ctx));
return llvm::make_unique<RelocationPass<Mips64ELType>>(ctx);
default:
llvm_unreachable("Unhandled arch");
}
@ -964,7 +964,7 @@ lld::elf::createMipsRelocationPass(MipsLinkingContext &ctx) {
case llvm::ELF::ET_DYN:
return createPass(ctx);
case llvm::ELF::ET_REL:
return std::unique_ptr<Pass>();
return nullptr;
default:
llvm_unreachable("Unhandled output file type");
}

View File

@ -502,13 +502,12 @@ lld::elf::createX86_64RelocationPass(const X86_64LinkingContext &ctx) {
switch (ctx.getOutputELFType()) {
case llvm::ELF::ET_EXEC:
if (ctx.isDynamic())
return std::unique_ptr<Pass>(new DynamicRelocationPass(ctx));
else
return std::unique_ptr<Pass>(new StaticRelocationPass(ctx));
return llvm::make_unique<DynamicRelocationPass>(ctx);
return llvm::make_unique<StaticRelocationPass>(ctx);
case llvm::ELF::ET_DYN:
return std::unique_ptr<Pass>(new DynamicRelocationPass(ctx));
return llvm::make_unique<DynamicRelocationPass>(ctx);
case llvm::ELF::ET_REL:
return std::unique_ptr<Pass>();
return nullptr;
default:
llvm_unreachable("Unhandled output file type");
}

View File

@ -521,7 +521,7 @@ private:
void addCompactUnwindPass(PassManager &pm, const MachOLinkingContext &ctx) {
assert(ctx.needsCompactUnwindPass());
pm.add(std::unique_ptr<Pass>(new CompactUnwindPass(ctx)));
pm.add(llvm::make_unique<CompactUnwindPass>(ctx));
}
} // end namesapce mach_o

View File

@ -177,7 +177,7 @@ private:
void addGOTPass(PassManager &pm, const MachOLinkingContext &ctx) {
assert(ctx.needsGOTPass());
pm.add(std::unique_ptr<Pass>(new GOTPass(ctx)));
pm.add(llvm::make_unique<GOTPass>(ctx));
}

View File

@ -484,11 +484,11 @@ void LayoutPass::perform(std::unique_ptr<MutableFile> &mergedFile) {
}
void addLayoutPass(PassManager &pm, const MachOLinkingContext &ctx) {
pm.add(std::unique_ptr<Pass>(new LayoutPass(
pm.add(llvm::make_unique<LayoutPass>(
ctx.registry(), [&](const DefinedAtom * left, const DefinedAtom * right,
bool & leftBeforeRight) ->bool {
return ctx.customAtomOrderer(left, right, leftBeforeRight);
})));
}));
}
} // namespace mach_o

View File

@ -122,7 +122,7 @@ private:
void addShimPass(PassManager &pm, const MachOLinkingContext &ctx) {
pm.add(std::unique_ptr<Pass>(new ShimPass(ctx)));
pm.add(llvm::make_unique<ShimPass>(ctx));
}
} // end namespace mach_o

View File

@ -345,12 +345,12 @@ std::string PECOFFLinkingContext::getPDBFilePath() const {
}
void PECOFFLinkingContext::addPasses(PassManager &pm) {
pm.add(std::unique_ptr<Pass>(new pecoff::PDBPass(*this)));
pm.add(std::unique_ptr<Pass>(new pecoff::EdataPass(*this)));
pm.add(std::unique_ptr<Pass>(new pecoff::IdataPass(*this)));
pm.add(std::unique_ptr<Pass>(new pecoff::OrderPass()));
pm.add(std::unique_ptr<Pass>(new pecoff::LoadConfigPass(*this)));
pm.add(std::unique_ptr<Pass>(new pecoff::InferSubsystemPass(*this)));
pm.add(llvm::make_unique<pecoff::PDBPass>(*this));
pm.add(llvm::make_unique<pecoff::EdataPass>(*this));
pm.add(llvm::make_unique<pecoff::IdataPass>(*this));
pm.add(llvm::make_unique<pecoff::OrderPass>());
pm.add(llvm::make_unique<pecoff::LoadConfigPass>(*this));
pm.add(llvm::make_unique<pecoff::InferSubsystemPass>(*this));
}
} // end namespace lld