[PATCH] D43587: [WebAssembly] Use make<> rather then make_unique<>

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 21 10:24:34 PST 2018


sbc100 created this revision.
Herald added subscribers: llvm-commits, aheejin.
sbc100 added a reviewer: ruiu.
sbc100 retitled this revision from "[WebAssebmly] Use make<> rather then make_unique<>" to "[WebAssembly] Use make<> rather then make_unique<>".
Herald added subscribers: sunfish, jgravelle-google, dschuff, jfb.
sbc100 added a comment.

Is my rational correct here?   Based on your feedback from my other change it seems like this should be preferred?


lld uses an arena allocator to one of allocations
like these can just use make<>.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D43587

Files:
  wasm/Writer.cpp


Index: wasm/Writer.cpp
===================================================================
--- wasm/Writer.cpp
+++ wasm/Writer.cpp
@@ -131,7 +131,6 @@
   std::vector<OutputSection *> OutputSections;
 
   std::unique_ptr<FileOutputBuffer> Buffer;
-  std::unique_ptr<SyntheticFunction> CtorFunction;
   std::string CtorFunctionBody;
 
   std::vector<OutputSegment *> Segments;
@@ -852,10 +851,10 @@
   ArrayRef<uint8_t> BodyArray(
       reinterpret_cast<const uint8_t *>(CtorFunctionBody.data()),
       CtorFunctionBody.size());
-  CtorFunction = llvm::make_unique<SyntheticFunction>(
-      Signature, BodyArray, WasmSym::CallCtors->getName());
-  CtorFunction->setOutputIndex(FunctionIndex);
-  DefinedFunctions.emplace_back(CtorFunction.get());
+  SyntheticFunction *F = make<SyntheticFunction>(Signature, BodyArray,
+                                                 WasmSym::CallCtors->getName());
+  F->setOutputIndex(FunctionIndex);
+  DefinedFunctions.emplace_back(F);
 }
 
 // Populate InitFunctions vector with init functions from all input objects.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43587.135288.patch
Type: text/x-patch
Size: 1059 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180221/cb761d64/attachment.bin>


More information about the llvm-commits mailing list