From 6104ac1cdfc11c523d99c2f7af196d98d6201eda Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Fri, 7 May 2021 15:42:17 +0200 Subject: [PATCH] Remove more imports of ranges namespace. --- libsolidity/analysis/FunctionCallGraph.cpp | 7 +++--- libsolidity/ast/ASTJsonConverter.cpp | 3 +-- libsolidity/formal/ModelCheckerSettings.cpp | 9 ++++--- .../analysis/FunctionCallGraph.cpp | 24 +++++++++++-------- test/tools/yulopti.cpp | 15 ++++++------ 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/libsolidity/analysis/FunctionCallGraph.cpp b/libsolidity/analysis/FunctionCallGraph.cpp index 92cd10cd9..0a4a4b437 100644 --- a/libsolidity/analysis/FunctionCallGraph.cpp +++ b/libsolidity/analysis/FunctionCallGraph.cpp @@ -25,7 +25,6 @@ #include 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(&functionType->declaration()); auto const* variable = dynamic_cast(&functionType->declaration()); @@ -305,7 +304,7 @@ ostream& solidity::frontend::operator<<(ostream& _out, CallGraph::Node const& _n auto const* modifier = dynamic_cast(callableDeclaration); auto typeToString = [](auto const& _var) -> string { return _var->type()->toString(true); }; - vector parameters = callableDeclaration->parameters() | views::transform(typeToString) | to>(); + vector parameters = callableDeclaration->parameters() | ranges::views::transform(typeToString) | ranges::to>(); string scopeName; if (!function || !function->isFree()) diff --git a/libsolidity/ast/ASTJsonConverter.cpp b/libsolidity/ast/ASTJsonConverter.cpp index 40cef6b8e..ea8662010 100644 --- a/libsolidity/ast/ASTJsonConverter.cpp +++ b/libsolidity/ast/ASTJsonConverter.cpp @@ -43,7 +43,6 @@ #include #include -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())) diff --git a/libsolidity/formal/ModelCheckerSettings.cpp b/libsolidity/formal/ModelCheckerSettings.cpp index f815ae95b..2f98b0697 100644 --- a/libsolidity/formal/ModelCheckerSettings.cpp +++ b/libsolidity/formal/ModelCheckerSettings.cpp @@ -22,7 +22,6 @@ #include using namespace std; -using namespace ranges; using namespace solidity; using namespace solidity::frontend; @@ -42,10 +41,10 @@ std::optional ModelCheckerTargets::fromString(string const& { set 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>()) + for (auto&& t: _targets | ranges::views::split(',') | ranges::to>()) { if (!targetStrings.count(t)) return {}; @@ -69,9 +68,9 @@ std::optional ModelCheckerContracts::fromString(string co if (_contracts == "default") return ModelCheckerContracts::Default(); - for (auto&& sourceContract: _contracts | views::split(',') | ranges::to>()) + for (auto&& sourceContract: _contracts | ranges::views::split(',') | ranges::to>()) { - auto&& names = sourceContract | views::split(':') | ranges::to>(); + auto&& names = sourceContract | ranges::views::split(':') | ranges::to>(); if (names.size() != 2 || names.at(0).empty() || names.at(1).empty()) return {}; chosen[names.at(0)].insert(names.at(1)); diff --git a/test/libsolidity/analysis/FunctionCallGraph.cpp b/test/libsolidity/analysis/FunctionCallGraph.cpp index 44687a7b4..e4cd3d066 100644 --- a/test/libsolidity/analysis/FunctionCallGraph.cpp +++ b/test/libsolidity/analysis/FunctionCallGraph.cpp @@ -47,7 +47,6 @@ #include using namespace std; -using namespace ranges; using namespace solidity::langutil; using namespace solidity::frontend; @@ -134,18 +133,18 @@ void checkCallGraphExpectations( auto notEmpty = [](set 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()) == (_callGraphs | views::keys | to()) && - (ranges::views::set_difference(_expectedCreatedContractSets | views::keys, _expectedEdges | views::keys)).empty(), + (_expectedEdges | ranges::views::keys | ranges::to()) == (_callGraphs | ranges::views::keys | ranges::to()) && + (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 edges; map> createdContractSets; map> 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>(); + createdContractSets[contractName] = callGraph.bytecodeDependency | + ranges::views::keys | + ranges::views::transform(getContractName) | + ranges::to>(); if (!callGraph.emittedEvents.empty()) - emittedEventSets[contractName] = callGraph.emittedEvents | views::transform(eventToString) | to>(); + emittedEventSets[contractName] = callGraph.emittedEvents | + ranges::views::transform(eventToString) | + ranges::to>(); } BOOST_CHECK_EQUAL(edges, _expectedEdges); @@ -179,7 +183,7 @@ ostream& operator<<(ostream& _out, EdgeNames const& _edgeNames) ostream& operator<<(ostream& _out, set const& _set) { - _out << "{" << (_set | views::join(", ") | to()) << "}"; + _out << "{" << (_set | ranges::views::join(", ") | ranges::to()) << "}"; return _out; } diff --git a/test/tools/yulopti.cpp b/test/tools/yulopti.cpp index 594d4c19c..3e403976f 100644 --- a/test/tools/yulopti.cpp +++ b/test/tools/yulopti.cpp @@ -65,7 +65,6 @@ #include using namespace std; -using namespace ranges; using namespace solidity; using namespace solidity::util; using namespace solidity::langutil; @@ -126,9 +125,9 @@ public: ); vector overlappingAbbreviations = - ranges::views::set_intersection(_extraOptions | views::keys, _optimizationSteps | views::keys) | - views::transform([](char _abbreviation){ return string(1, _abbreviation); }) | - to(); + ranges::views::set_intersection(_extraOptions | ranges::views::keys, _optimizationSteps | ranges::views::keys) | + ranges::views::transform([](char _abbreviation){ return string(1, _abbreviation); }) | + ranges::to(); yulAssert( overlappingAbbreviations.empty(), @@ -140,9 +139,9 @@ public: ); vector> sortedOptions = - views::concat(_optimizationSteps, _extraOptions) | - to>>() | - actions::sort([](tuple const& _a, tuple const& _b) { + ranges::views::concat(_optimizationSteps, _extraOptions) | + ranges::to>>() | + ranges::actions::sort([](tuple const& _a, tuple 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(longestDescriptionLength)) << setiosflags(ios::left) << name << " "; cout << endl;