diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2020-11-19 20:59:14 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-19 20:59:14 -0800 |
commit | de5e7365957b3eaf0d9aa05eea4ee759efb67ca4 (patch) | |
tree | 397149ae1909c35fa6851a87c289ec5427f647b2 /src/passes/FuncCastEmulation.cpp | |
parent | d0bc3811f00fe90762a9bee19bf354f780704ce5 (diff) | |
download | binaryen-de5e7365957b3eaf0d9aa05eea4ee759efb67ca4.tar.gz binaryen-de5e7365957b3eaf0d9aa05eea4ee759efb67ca4.tar.bz2 binaryen-de5e7365957b3eaf0d9aa05eea4ee759efb67ca4.zip |
[wasm-builder] Construct module elements as unique_ptrs (#3391)
When Functions, Globals, Events, and Exports are added to a module, if they are
not already in std::unique_ptrs, they are wrapped in a new std::unique_ptr owned
by the Module. This adds an extra layer of indirection when accessing those
elements that can be avoided by allocating those elements as std::unique_ptrs.
This PR updates wasm-builder to allocate module elements via std::make_unique
rather than `new`. In the future, we should remove the raw pointer versions of
Module::add* to encourage using std::unique_ptrs more broadly.
Diffstat (limited to 'src/passes/FuncCastEmulation.cpp')
-rw-r--r-- | src/passes/FuncCastEmulation.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/passes/FuncCastEmulation.cpp b/src/passes/FuncCastEmulation.cpp index a164b4264..ba6d1d583 100644 --- a/src/passes/FuncCastEmulation.cpp +++ b/src/passes/FuncCastEmulation.cpp @@ -209,12 +209,12 @@ private: for (Index i = 0; i < NUM_PARAMS; i++) { thunkParams.push_back(Type::i64); } - auto* thunkFunc = + auto thunkFunc = builder.makeFunction(thunk, Signature(Type(thunkParams), Type::i64), {}, // no vars toABI(call, module)); - module->addFunction(thunkFunc); + module->addFunction(std::move(thunkFunc)); return thunk; } }; |