Use llvm::make_unique.
authorRui Ueyama <ruiu@google.com>
Tue, 14 Oct 2014 19:43:37 +0000 (19:43 +0000)
committerRui Ueyama <ruiu@google.com>
Tue, 14 Oct 2014 19:43:37 +0000 (19:43 +0000)
llvm-svn: 219709

lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
lld/lib/ReaderWriter/PECOFF/Pass.cpp
lld/lib/ReaderWriter/PECOFF/ReaderImportHeader.cpp

index 659766d..c971b78 100644 (file)
@@ -90,17 +90,15 @@ std::unique_ptr<File> PECOFFLinkingContext::createUndefinedSymbolFile() const {
 bool PECOFFLinkingContext::createImplicitFiles(
     std::vector<std::unique_ptr<File>> &) {
   // Create a file for __ImageBase.
-  std::unique_ptr<SimpleFileNode> fileNode(
-      new SimpleFileNode("Implicit Files"));
-  std::unique_ptr<File> linkerGeneratedSymFile(
-      new pecoff::LinkerGeneratedSymbolFile(*this));
-  fileNode->appendInputFile(std::move(linkerGeneratedSymFile));
+  auto fileNode = llvm::make_unique<SimpleFileNode>("Implicit Files");
+  fileNode->appendInputFile(
+      llvm::make_unique<pecoff::LinkerGeneratedSymbolFile>(*this));
   getInputGraph().addInputElement(std::move(fileNode));
 
   // Create a file for _imp_ symbols.
-  std::unique_ptr<SimpleFileNode> impFileNode(new SimpleFileNode("imp"));
+  auto impFileNode = llvm::make_unique<SimpleFileNode>("imp");
   impFileNode->appendInputFile(
-      std::unique_ptr<File>(new pecoff::LocallyImportedSymbolFile(*this)));
+      llvm::make_unique<pecoff::LocallyImportedSymbolFile>(*this));
   getInputGraph().addInputElement(std::move(impFileNode));
 
   std::shared_ptr<pecoff::ResolvableSymbols> syms(
@@ -108,14 +106,14 @@ bool PECOFFLinkingContext::createImplicitFiles(
   getInputGraph().registerObserver([=](File *file) { syms->add(file); });
 
   // Create a file for dllexported symbols.
-  std::unique_ptr<SimpleFileNode> exportNode(new SimpleFileNode("<export>"));
-  auto *renameFile = new pecoff::ExportedSymbolRenameFile(*this, syms);
-  exportNode->appendInputFile(std::unique_ptr<File>(renameFile));
+  auto exportNode = llvm::make_unique<SimpleFileNode>("<export>");
+  exportNode->appendInputFile(
+      llvm::make_unique<pecoff::ExportedSymbolRenameFile>(*this, syms));
   getLibraryGroup()->addFile(std::move(exportNode));
 
   // Create a file for the entry point function.
   getEntryNode()->appendInputFile(
-      std::unique_ptr<File>(new pecoff::EntryPointFile(*this, syms)));
+      llvm::make_unique<pecoff::EntryPointFile>(*this, syms));
   return true;
 }
 
index cb31e44..e756bf5 100644 (file)
@@ -19,8 +19,8 @@ namespace pecoff {
 static void addReloc(COFFBaseDefinedAtom *atom, const Atom *target,
                      size_t offsetInAtom, Reference::KindArch arch,
                      Reference::KindValue relType) {
-  auto *ref = new COFFReference(target, offsetInAtom, relType, arch);
-  atom->addReference(std::unique_ptr<COFFReference>(ref));
+  atom->addReference(llvm::make_unique<COFFReference>(
+      target, offsetInAtom, relType, arch));
 }
 
 void addDir32Reloc(COFFBaseDefinedAtom *atom, const Atom *target,
index d20b455..258887a 100644 (file)
@@ -343,7 +343,7 @@ private:
 
 void Registry::addSupportCOFFImportLibraries(PECOFFLinkingContext &ctx) {
   MachineTypes machine = ctx.getMachineType();
-  add(std::unique_ptr<Reader>(new COFFImportLibraryReader(machine)));
+  add(llvm::make_unique<COFFImportLibraryReader>(machine));
 }
 
 } // end namespace lld