mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #8914 from random-internet-cat/down-with-unique-ptr
Down with unique_ptr!
This commit is contained in:
commit
84092edc5d
@ -582,9 +582,9 @@ string const* CompilerStack::sourceMapping(string const& _contractName) const
|
||||
if (!c.sourceMapping)
|
||||
{
|
||||
if (auto items = assemblyItems(_contractName))
|
||||
c.sourceMapping = make_unique<string>(evmasm::AssemblyItem::computeSourceMapping(*items, sourceIndices()));
|
||||
c.sourceMapping.emplace(evmasm::AssemblyItem::computeSourceMapping(*items, sourceIndices()));
|
||||
}
|
||||
return c.sourceMapping.get();
|
||||
return c.sourceMapping ? &*c.sourceMapping : nullptr;
|
||||
}
|
||||
|
||||
string const* CompilerStack::runtimeSourceMapping(string const& _contractName) const
|
||||
@ -596,11 +596,11 @@ string const* CompilerStack::runtimeSourceMapping(string const& _contractName) c
|
||||
if (!c.runtimeSourceMapping)
|
||||
{
|
||||
if (auto items = runtimeAssemblyItems(_contractName))
|
||||
c.runtimeSourceMapping = make_unique<string>(
|
||||
c.runtimeSourceMapping.emplace(
|
||||
evmasm::AssemblyItem::computeSourceMapping(*items, sourceIndices())
|
||||
);
|
||||
}
|
||||
return c.runtimeSourceMapping.get();
|
||||
return c.runtimeSourceMapping ? &*c.runtimeSourceMapping : nullptr;
|
||||
}
|
||||
|
||||
std::string const CompilerStack::filesystemFriendlyName(string const& _contractName) const
|
||||
|
@ -348,8 +348,8 @@ private:
|
||||
util::LazyInit<Json::Value const> storageLayout;
|
||||
util::LazyInit<Json::Value const> userDocumentation;
|
||||
util::LazyInit<Json::Value const> devDocumentation;
|
||||
mutable std::unique_ptr<std::string const> sourceMapping;
|
||||
mutable std::unique_ptr<std::string const> runtimeSourceMapping;
|
||||
mutable std::optional<std::string const> sourceMapping;
|
||||
mutable std::optional<std::string const> runtimeSourceMapping;
|
||||
};
|
||||
|
||||
/// Loads the missing sources from @a _ast (named @a _path) using the callback
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
namespace solidity::yul::wasm
|
||||
{
|
||||
@ -76,7 +77,7 @@ struct FunctionImport {
|
||||
std::string externalName;
|
||||
std::string internalName;
|
||||
std::vector<std::string> paramTypes;
|
||||
std::unique_ptr<std::string> returnType;
|
||||
std::optional<std::string> returnType;
|
||||
};
|
||||
|
||||
struct FunctionDefinition
|
||||
|
@ -29,6 +29,8 @@
|
||||
|
||||
#include <liblangutil/Exceptions.h>
|
||||
|
||||
#include <optional>
|
||||
|
||||
using namespace std;
|
||||
using namespace solidity;
|
||||
using namespace solidity::yul;
|
||||
@ -125,7 +127,7 @@ wasm::Expression WasmCodeTransform::operator()(FunctionCall const& _call)
|
||||
builtin->name.str().substr(4),
|
||||
builtin->name.str(),
|
||||
{},
|
||||
builtin->returns.empty() ? nullptr : make_unique<string>(builtin->returns.front().str())
|
||||
builtin->returns.empty() ? nullopt : make_optional<string>(builtin->returns.front().str())
|
||||
};
|
||||
for (auto const& param: builtin->parameters)
|
||||
imp.paramTypes.emplace_back(param.str());
|
||||
|
@ -89,7 +89,10 @@ int registerTests(
|
||||
}
|
||||
else
|
||||
{
|
||||
static vector<unique_ptr<string>> filenames;
|
||||
// This must be a vector of unique_ptrs because Boost.Test keeps the equivalent of a string_view to the filename
|
||||
// that is passed in. If the strings were stored directly in the vector, pointers/references to them would be
|
||||
// invalidated on reallocation.
|
||||
static vector<unique_ptr<string const>> filenames;
|
||||
|
||||
filenames.emplace_back(make_unique<string>(_path.string()));
|
||||
_suite.add(make_test_case(
|
||||
|
Loading…
Reference in New Issue
Block a user