[PATCH] D81111: lld: use `std::make_unique` rather than spelling out types twice

Saleem Abdulrasool via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 3 11:32:42 PDT 2020


compnerd created this revision.
compnerd added reviewers: smeenai, int3.
compnerd added a project: lld.
Herald added a project: LLVM.

The LLVM code base already uses C++14, use `std::make_unique`
to avoid the explicit constructor invocation via `new` and to avoid
spelling out the type twice.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81111

Files:
  lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp


Index: lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
===================================================================
--- lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
+++ lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
@@ -1401,7 +1401,7 @@
 llvm::Expected<std::unique_ptr<lld::File>>
 objectToAtoms(const NormalizedFile &normalizedFile, StringRef path,
               bool copyRefs) {
-  std::unique_ptr<MachOFile> file(new MachOFile(path));
+  auto file = std::make_unique<MachOFile>(path);
   if (auto ec = normalizedObjectToAtoms(file.get(), normalizedFile, copyRefs))
     return std::move(ec);
   return std::unique_ptr<File>(std::move(file));
@@ -1411,7 +1411,7 @@
 dylibToAtoms(const NormalizedFile &normalizedFile, StringRef path,
              bool copyRefs) {
   // Instantiate SharedLibraryFile object.
-  std::unique_ptr<MachODylibFile> file(new MachODylibFile(path));
+  auto file = std::make_unique<MachODylibFile>(path);
   if (auto ec = normalizedDylibToAtoms(file.get(), normalizedFile, copyRefs))
     return std::move(ec);
   return std::unique_ptr<File>(std::move(file));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81111.268262.patch
Type: text/x-patch
Size: 1131 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200603/e7652e31/attachment.bin>


More information about the llvm-commits mailing list