mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Remove more imports of ranges namespace.
This commit is contained in:
parent
c69add1682
commit
6104ac1cdf
@ -25,7 +25,6 @@
|
||||
#include <range/v3/view/transform.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace ranges;
|
||||
using namespace solidity::frontend;
|
||||
using namespace solidity::util;
|
||||
|
||||
@ -35,7 +34,7 @@ CallGraph FunctionCallGraphBuilder::buildCreationGraph(ContractDefinition const&
|
||||
solAssert(builder.m_currentNode == CallGraph::Node(CallGraph::SpecialNode::Entry), "");
|
||||
|
||||
// Create graph for constructor, state vars, etc
|
||||
for (ContractDefinition const* base: _contract.annotation().linearizedBaseContracts | views::reverse)
|
||||
for (ContractDefinition const* base: _contract.annotation().linearizedBaseContracts | ranges::views::reverse)
|
||||
{
|
||||
// The constructor and functions called in state variable initial assignments should have
|
||||
// an edge from Entry
|
||||
@ -76,7 +75,7 @@ CallGraph FunctionCallGraphBuilder::buildDeployedGraph(
|
||||
auto getSecondElement = [](auto const& _tuple){ return get<1>(_tuple); };
|
||||
|
||||
// Create graph for all publicly reachable functions
|
||||
for (FunctionTypePointer functionType: _contract.interfaceFunctionList() | views::transform(getSecondElement))
|
||||
for (FunctionTypePointer functionType: _contract.interfaceFunctionList() | ranges::views::transform(getSecondElement))
|
||||
{
|
||||
auto const* function = dynamic_cast<FunctionDefinition const*>(&functionType->declaration());
|
||||
auto const* variable = dynamic_cast<VariableDeclaration const*>(&functionType->declaration());
|
||||
@ -305,7 +304,7 @@ ostream& solidity::frontend::operator<<(ostream& _out, CallGraph::Node const& _n
|
||||
auto const* modifier = dynamic_cast<ModifierDefinition const *>(callableDeclaration);
|
||||
|
||||
auto typeToString = [](auto const& _var) -> string { return _var->type()->toString(true); };
|
||||
vector<string> parameters = callableDeclaration->parameters() | views::transform(typeToString) | to<vector<string>>();
|
||||
vector<string> parameters = callableDeclaration->parameters() | ranges::views::transform(typeToString) | ranges::to<vector<string>>();
|
||||
|
||||
string scopeName;
|
||||
if (!function || !function->isFree())
|
||||
|
@ -43,7 +43,6 @@
|
||||
#include <type_traits>
|
||||
#include <range/v3/view/map.hpp>
|
||||
|
||||
using namespace ranges;
|
||||
using namespace std;
|
||||
using namespace solidity::langutil;
|
||||
|
||||
@ -271,7 +270,7 @@ bool ASTJsonConverter::visit(ContractDefinition const& _node)
|
||||
make_pair("contractKind", contractKind(_node.contractKind())),
|
||||
make_pair("abstract", _node.abstract()),
|
||||
make_pair("baseContracts", toJson(_node.baseContracts())),
|
||||
make_pair("contractDependencies", getContainerIds(_node.annotation().contractDependencies | views::keys)),
|
||||
make_pair("contractDependencies", getContainerIds(_node.annotation().contractDependencies | ranges::views::keys)),
|
||||
make_pair("usedErrors", getContainerIds(_node.interfaceErrors(false))),
|
||||
make_pair("nodes", toJson(_node.subNodes())),
|
||||
make_pair("scope", idOrNull(_node.scope()))
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include <range/v3/view.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace ranges;
|
||||
using namespace solidity;
|
||||
using namespace solidity::frontend;
|
||||
|
||||
@ -42,10 +41,10 @@ std::optional<ModelCheckerTargets> ModelCheckerTargets::fromString(string const&
|
||||
{
|
||||
set<TargetType> chosenTargets;
|
||||
if (_targets == "default")
|
||||
for (auto&& v: targetStrings | views::values)
|
||||
for (auto&& v: targetStrings | ranges::views::values)
|
||||
chosenTargets.insert(v);
|
||||
else
|
||||
for (auto&& t: _targets | views::split(',') | ranges::to<vector<string>>())
|
||||
for (auto&& t: _targets | ranges::views::split(',') | ranges::to<vector<string>>())
|
||||
{
|
||||
if (!targetStrings.count(t))
|
||||
return {};
|
||||
@ -69,9 +68,9 @@ std::optional<ModelCheckerContracts> ModelCheckerContracts::fromString(string co
|
||||
if (_contracts == "default")
|
||||
return ModelCheckerContracts::Default();
|
||||
|
||||
for (auto&& sourceContract: _contracts | views::split(',') | ranges::to<vector<string>>())
|
||||
for (auto&& sourceContract: _contracts | ranges::views::split(',') | ranges::to<vector<string>>())
|
||||
{
|
||||
auto&& names = sourceContract | views::split(':') | ranges::to<vector<string>>();
|
||||
auto&& names = sourceContract | ranges::views::split(':') | ranges::to<vector<string>>();
|
||||
if (names.size() != 2 || names.at(0).empty() || names.at(1).empty())
|
||||
return {};
|
||||
chosen[names.at(0)].insert(names.at(1));
|
||||
|
@ -47,7 +47,6 @@
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
using namespace ranges;
|
||||
using namespace solidity::langutil;
|
||||
using namespace solidity::frontend;
|
||||
|
||||
@ -134,18 +133,18 @@ void checkCallGraphExpectations(
|
||||
auto notEmpty = [](set<string> const& _set){ return !_set.empty(); };
|
||||
|
||||
soltestAssert(
|
||||
(_expectedCreatedContractSets | views::values | views::remove_if(notEmpty)).empty(),
|
||||
(_expectedCreatedContractSets | ranges::views::values | ranges::views::remove_if(notEmpty)).empty(),
|
||||
"Contracts that are not expected to create other contracts should not be included in _expectedCreatedContractSets."
|
||||
);
|
||||
soltestAssert(
|
||||
(_expectedEdges | views::keys | to<set>()) == (_callGraphs | views::keys | to<set>()) &&
|
||||
(ranges::views::set_difference(_expectedCreatedContractSets | views::keys, _expectedEdges | views::keys)).empty(),
|
||||
(_expectedEdges | ranges::views::keys | ranges::to<set>()) == (_callGraphs | ranges::views::keys | ranges::to<set>()) &&
|
||||
(ranges::views::set_difference(_expectedCreatedContractSets | ranges::views::keys, _expectedEdges | ranges::views::keys)).empty(),
|
||||
"Contracts listed in expectations do not match contracts actually found in the source file or in other expectations."
|
||||
);
|
||||
for (string const& contractName: _expectedEdges | views::keys)
|
||||
for (string const& contractName: _expectedEdges | ranges::views::keys)
|
||||
{
|
||||
soltestAssert(
|
||||
(ranges::views::set_difference(valueOrDefault(_expectedCreatedContractSets, contractName, {}), _expectedEdges | views::keys)).empty(),
|
||||
(ranges::views::set_difference(valueOrDefault(_expectedCreatedContractSets, contractName, {}), _expectedEdges | ranges::views::keys)).empty(),
|
||||
"Inconsistent expectations: contract expected to be created but not to be present in the source file."
|
||||
);
|
||||
}
|
||||
@ -153,16 +152,21 @@ void checkCallGraphExpectations(
|
||||
map<string, EdgeNames> edges;
|
||||
map<string, set<string>> createdContractSets;
|
||||
map<string, set<string>> emittedEventSets;
|
||||
for (string const& contractName: _expectedEdges | views::keys)
|
||||
for (string const& contractName: _expectedEdges | ranges::views::keys)
|
||||
{
|
||||
soltestAssert(_callGraphs.at(contractName) != nullptr, "");
|
||||
CallGraph const& callGraph = *_callGraphs.at(contractName);
|
||||
|
||||
edges[contractName] = edgeNames(callGraph.edges);
|
||||
if (!callGraph.bytecodeDependency.empty())
|
||||
createdContractSets[contractName] = callGraph.bytecodeDependency | views::keys | views::transform(getContractName) | to<set<string>>();
|
||||
createdContractSets[contractName] = callGraph.bytecodeDependency |
|
||||
ranges::views::keys |
|
||||
ranges::views::transform(getContractName) |
|
||||
ranges::to<set<string>>();
|
||||
if (!callGraph.emittedEvents.empty())
|
||||
emittedEventSets[contractName] = callGraph.emittedEvents | views::transform(eventToString) | to<set<string>>();
|
||||
emittedEventSets[contractName] = callGraph.emittedEvents |
|
||||
ranges::views::transform(eventToString) |
|
||||
ranges::to<set<string>>();
|
||||
}
|
||||
|
||||
BOOST_CHECK_EQUAL(edges, _expectedEdges);
|
||||
@ -179,7 +183,7 @@ ostream& operator<<(ostream& _out, EdgeNames const& _edgeNames)
|
||||
|
||||
ostream& operator<<(ostream& _out, set<string> const& _set)
|
||||
{
|
||||
_out << "{" << (_set | views::join(", ") | to<string>()) << "}";
|
||||
_out << "{" << (_set | ranges::views::join(", ") | ranges::to<string>()) << "}";
|
||||
return _out;
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,6 @@
|
||||
#include <variant>
|
||||
|
||||
using namespace std;
|
||||
using namespace ranges;
|
||||
using namespace solidity;
|
||||
using namespace solidity::util;
|
||||
using namespace solidity::langutil;
|
||||
@ -126,9 +125,9 @@ public:
|
||||
);
|
||||
|
||||
vector<string> overlappingAbbreviations =
|
||||
ranges::views::set_intersection(_extraOptions | views::keys, _optimizationSteps | views::keys) |
|
||||
views::transform([](char _abbreviation){ return string(1, _abbreviation); }) |
|
||||
to<vector>();
|
||||
ranges::views::set_intersection(_extraOptions | ranges::views::keys, _optimizationSteps | ranges::views::keys) |
|
||||
ranges::views::transform([](char _abbreviation){ return string(1, _abbreviation); }) |
|
||||
ranges::to<vector>();
|
||||
|
||||
yulAssert(
|
||||
overlappingAbbreviations.empty(),
|
||||
@ -140,9 +139,9 @@ public:
|
||||
);
|
||||
|
||||
vector<tuple<char, string>> sortedOptions =
|
||||
views::concat(_optimizationSteps, _extraOptions) |
|
||||
to<vector<tuple<char, string>>>() |
|
||||
actions::sort([](tuple<char, string> const& _a, tuple<char, string> const& _b) {
|
||||
ranges::views::concat(_optimizationSteps, _extraOptions) |
|
||||
ranges::to<vector<tuple<char, string>>>() |
|
||||
ranges::actions::sort([](tuple<char, string> const& _a, tuple<char, string> const& _b) {
|
||||
return (
|
||||
!boost::algorithm::iequals(get<1>(_a), get<1>(_b)) ?
|
||||
boost::algorithm::lexicographical_compare(get<1>(_a), get<1>(_b), boost::algorithm::is_iless()) :
|
||||
@ -154,7 +153,7 @@ public:
|
||||
size_t rows = (sortedOptions.size() - 1) / _columns + 1;
|
||||
for (size_t row = 0; row < rows; ++row)
|
||||
{
|
||||
for (auto const& [key, name]: sortedOptions | views::drop(row) | views::stride(rows))
|
||||
for (auto const& [key, name]: sortedOptions | ranges::views::drop(row) | ranges::views::stride(rows))
|
||||
cout << key << ": " << setw(static_cast<int>(longestDescriptionLength)) << setiosflags(ios::left) << name << " ";
|
||||
|
||||
cout << endl;
|
||||
|
Loading…
Reference in New Issue
Block a user