diff --git a/libsolidity/analysis/ConstantEvaluator.cpp b/libsolidity/analysis/ConstantEvaluator.cpp index 7fde36ec0ebb..8e18183a81f9 100644 --- a/libsolidity/analysis/ConstantEvaluator.cpp +++ b/libsolidity/analysis/ConstantEvaluator.cpp @@ -29,7 +29,6 @@ #include -using namespace std; using namespace solidity; using namespace solidity::frontend; using namespace solidity::langutil; @@ -47,9 +46,9 @@ bool fitsPrecisionExp(bigint const& _base, bigint const& _exp) solAssert(_base > 0, ""); - size_t const bitsMax = 4096; + std::size_t const bitsMax = 4096; - size_t mostSignificantBaseBit = static_cast(boost::multiprecision::msb(_base)); + std::size_t mostSignificantBaseBit = static_cast(boost::multiprecision::msb(_base)); if (mostSignificantBaseBit == 0) // _base == 1 return true; if (mostSignificantBaseBit > bitsMax) // _base >= 2 ^ 4096 @@ -68,7 +67,7 @@ bool fitsPrecisionBase2(bigint const& _mantissa, uint32_t _expBase2) } -optional ConstantEvaluator::evaluateBinaryOperator(Token _operator, rational const& _left, rational const& _right) +std::optional ConstantEvaluator::evaluateBinaryOperator(Token _operator, rational const& _left, rational const& _right) { bool fractional = _left.denominator() != 1 || _right.denominator() != 1; switch (_operator) @@ -76,17 +75,17 @@ optional ConstantEvaluator::evaluateBinaryOperator(Token _operator, ra //bit operations will only be enabled for integers and fixed types that resemble integers case Token::BitOr: if (fractional) - return nullopt; + return std::nullopt; else return _left.numerator() | _right.numerator(); case Token::BitXor: if (fractional) - return nullopt; + return std::nullopt; else return _left.numerator() ^ _right.numerator(); case Token::BitAnd: if (fractional) - return nullopt; + return std::nullopt; else return _left.numerator() & _right.numerator(); case Token::Add: return _left + _right; @@ -94,12 +93,12 @@ optional ConstantEvaluator::evaluateBinaryOperator(Token _operator, ra case Token::Mul: return _left * _right; case Token::Div: if (_right == rational(0)) - return nullopt; + return std::nullopt; else return _left / _right; case Token::Mod: if (_right == rational(0)) - return nullopt; + return std::nullopt; else if (fractional) { rational tempValue = _left / _right; @@ -111,7 +110,7 @@ optional ConstantEvaluator::evaluateBinaryOperator(Token _operator, ra case Token::Exp: { if (_right.denominator() != 1) - return nullopt; + return std::nullopt; bigint const& exp = _right.numerator(); // x ** 0 = 1 @@ -127,13 +126,13 @@ optional ConstantEvaluator::evaluateBinaryOperator(Token _operator, ra } else { - if (abs(exp) > numeric_limits::max()) - return nullopt; // This will need too much memory to represent. + if (abs(exp) > std::numeric_limits::max()) + return std::nullopt; // This will need too much memory to represent. uint32_t absExp = bigint(abs(exp)).convert_to(); if (!fitsPrecisionExp(abs(_left.numerator()), absExp) || !fitsPrecisionExp(abs(_left.denominator()), absExp)) - return nullopt; + return std::nullopt; static auto const optimizedPow = [](bigint const& _base, uint32_t _exponent) -> bigint { if (_base == 1) @@ -158,18 +157,18 @@ optional ConstantEvaluator::evaluateBinaryOperator(Token _operator, ra case Token::SHL: { if (fractional) - return nullopt; + return std::nullopt; else if (_right < 0) - return nullopt; - else if (_right > numeric_limits::max()) - return nullopt; + return std::nullopt; + else if (_right > std::numeric_limits::max()) + return std::nullopt; if (_left.numerator() == 0) return 0; else { uint32_t exponent = _right.numerator().convert_to(); if (!fitsPrecisionBase2(abs(_left.numerator()), exponent)) - return nullopt; + return std::nullopt; return _left.numerator() * boost::multiprecision::pow(bigint(2), exponent); } break; @@ -179,11 +178,11 @@ optional ConstantEvaluator::evaluateBinaryOperator(Token _operator, ra case Token::SAR: { if (fractional) - return nullopt; + return std::nullopt; else if (_right < 0) - return nullopt; - else if (_right > numeric_limits::max()) - return nullopt; + return std::nullopt; + else if (_right > std::numeric_limits::max()) + return std::nullopt; if (_left.numerator() == 0) return 0; else @@ -209,60 +208,60 @@ optional ConstantEvaluator::evaluateBinaryOperator(Token _operator, ra break; } default: - return nullopt; + return std::nullopt; } } -optional ConstantEvaluator::evaluateUnaryOperator(Token _operator, rational const& _input) +std::optional ConstantEvaluator::evaluateUnaryOperator(Token _operator, rational const& _input) { switch (_operator) { case Token::BitNot: if (_input.denominator() != 1) - return nullopt; + return std::nullopt; else return ~_input.numerator(); case Token::Sub: return -_input; default: - return nullopt; + return std::nullopt; } } namespace { -optional convertType(rational const& _value, Type const& _type) +std::optional convertType(rational const& _value, Type const& _type) { if (_type.category() == Type::Category::RationalNumber) return TypedRational{TypeProvider::rationalNumber(_value), _value}; else if (auto const* integerType = dynamic_cast(&_type)) { if (_value > integerType->maxValue() || _value < integerType->minValue()) - return nullopt; + return std::nullopt; else return TypedRational{&_type, _value.numerator() / _value.denominator()}; } else - return nullopt; + return std::nullopt; } -optional convertType(optional const& _value, Type const& _type) +std::optional convertType(std::optional const& _value, Type const& _type) { - return _value ? convertType(_value->value, _type) : nullopt; + return _value ? convertType(_value->value, _type) : std::nullopt; } -optional constantToTypedValue(Type const& _type) +std::optional constantToTypedValue(Type const& _type) { if (_type.category() == Type::Category::RationalNumber) return TypedRational{&_type, dynamic_cast(_type).value()}; else - return nullopt; + return std::nullopt; } } -optional ConstantEvaluator::evaluate( +std::optional ConstantEvaluator::evaluate( langutil::ErrorReporter& _errorReporter, Expression const& _expr ) @@ -271,7 +270,7 @@ optional ConstantEvaluator::evaluate( } -optional ConstantEvaluator::evaluate(ASTNode const& _node) +std::optional ConstantEvaluator::evaluate(ASTNode const& _node) { if (!m_values.count(&_node)) { @@ -280,7 +279,7 @@ optional ConstantEvaluator::evaluate(ASTNode const& _node) solAssert(varDecl->isConstant(), ""); // In some circumstances, we do not yet have a type for the variable. if (!varDecl->value() || !varDecl->type()) - m_values[&_node] = nullopt; + m_values[&_node] = std::nullopt; else { m_depth++; @@ -298,7 +297,7 @@ optional ConstantEvaluator::evaluate(ASTNode const& _node) { expression->accept(*this); if (!m_values.count(&_node)) - m_values[&_node] = nullopt; + m_values[&_node] = std::nullopt; } } return m_values.at(&_node); @@ -306,7 +305,7 @@ optional ConstantEvaluator::evaluate(ASTNode const& _node) void ConstantEvaluator::endVisit(UnaryOperation const& _operation) { - optional value = evaluate(_operation.subExpression()); + std::optional value = evaluate(_operation.subExpression()); if (!value) return; @@ -317,9 +316,9 @@ void ConstantEvaluator::endVisit(UnaryOperation const& _operation) if (!value) return; - if (optional result = evaluateUnaryOperator(_operation.getOperator(), value->value)) + if (std::optional result = evaluateUnaryOperator(_operation.getOperator(), value->value)) { - optional convertedValue = convertType(*result, *resultType); + std::optional convertedValue = convertType(*result, *resultType); if (!convertedValue) m_errorReporter.fatalTypeError( 3667_error, @@ -332,8 +331,8 @@ void ConstantEvaluator::endVisit(UnaryOperation const& _operation) void ConstantEvaluator::endVisit(BinaryOperation const& _operation) { - optional left = evaluate(_operation.leftExpression()); - optional right = evaluate(_operation.rightExpression()); + std::optional left = evaluate(_operation.leftExpression()); + std::optional right = evaluate(_operation.rightExpression()); if (!left || !right) return; @@ -349,7 +348,7 @@ void ConstantEvaluator::endVisit(BinaryOperation const& _operation) 6020_error, _operation.location(), "Operator " + - string(TokenTraits::toString(_operation.getOperator())) + + std::string(TokenTraits::toString(_operation.getOperator())) + " not compatible with types " + left->type->toString() + " and " + @@ -363,9 +362,9 @@ void ConstantEvaluator::endVisit(BinaryOperation const& _operation) if (!left || !right) return; - if (optional value = evaluateBinaryOperator(_operation.getOperator(), left->value, right->value)) + if (std::optional value = evaluateBinaryOperator(_operation.getOperator(), left->value, right->value)) { - optional convertedValue = convertType(*value, *resultType); + std::optional convertedValue = convertType(*value, *resultType); if (!convertedValue) m_errorReporter.fatalTypeError( 2643_error, diff --git a/libsolidity/analysis/ContractLevelChecker.cpp b/libsolidity/analysis/ContractLevelChecker.cpp index e7e7041a0ff1..eaeaf4851710 100644 --- a/libsolidity/analysis/ContractLevelChecker.cpp +++ b/libsolidity/analysis/ContractLevelChecker.cpp @@ -32,7 +32,6 @@ #include -using namespace std; using namespace solidity; using namespace solidity::langutil; using namespace solidity::frontend; @@ -49,10 +48,10 @@ bool hasEqualExternalCallableParameters(T const& _a, B const& _b) } template -map> filterDeclarations( - map> const& _declarations) +std::map> filterDeclarations( + std::map> const& _declarations) { - map> filteredDeclarations; + std::map> filteredDeclarations; for (auto const& [name, overloads]: _declarations) for (auto const* declaration: overloads) if (auto typedDeclaration = dynamic_cast(declaration)) @@ -106,7 +105,7 @@ void ContractLevelChecker::checkDuplicateFunctions(ContractDefinition const& _co { /// Checks that two functions with the same name defined in this contract have different /// argument types and that there is at most one constructor. - map> functions; + std::map> functions; FunctionDefinition const* constructor = nullptr; FunctionDefinition const* fallback = nullptr; FunctionDefinition const* receive = nullptr; @@ -157,7 +156,7 @@ void ContractLevelChecker::checkDuplicateEvents(ContractDefinition const& _contr { /// Checks that two events with the same name defined in this contract have different /// argument types - map> events; + std::map> events; for (auto const* contract: _contract.annotation().linearizedBaseContracts) for (EventDefinition const* event: contract->events()) events[event->name()].push_back(event); @@ -195,12 +194,12 @@ void ContractLevelChecker::checkReceiveFunction(ContractDefinition const& _contr } template -void ContractLevelChecker::findDuplicateDefinitions(map> const& _definitions) +void ContractLevelChecker::findDuplicateDefinitions(std::map> const& _definitions) { for (auto const& it: _definitions) { - vector const& overloads = it.second; - set reported; + std::vector const& overloads = it.second; + std::set reported; for (size_t i = 0; i < overloads.size() && !reported.count(i); ++i) { SecondarySourceLocation ssl; @@ -228,15 +227,15 @@ void ContractLevelChecker::findDuplicateDefinitions(map> const if (ssl.infos.size() > 0) { ErrorId error; - string message; - if constexpr (is_same_v) + std::string message; + if constexpr (std::is_same_v) { error = 1686_error; message = "Function with same name and parameter types defined twice."; } else { - static_assert(is_same_v, "Expected \"FunctionDefinition const*\" or \"EventDefinition const*\""); + static_assert(std::is_same_v, "Expected \"FunctionDefinition const*\" or \"EventDefinition const*\""); error = 5883_error; message = "Event with same name and parameter types defined twice."; } @@ -258,7 +257,7 @@ void ContractLevelChecker::checkAbstractDefinitions(ContractDefinition const& _c { // Collects functions, static variable getters and modifiers. If they // override (unimplemented) base class ones, they are replaced. - set proxies; + std::set proxies; auto registerProxy = [&proxies](OverrideProxy const& _overrideProxy) { @@ -323,7 +322,7 @@ void ContractLevelChecker::checkAbstractDefinitions(ContractDefinition const& _c void ContractLevelChecker::checkBaseConstructorArguments(ContractDefinition const& _contract) { - vector const& bases = _contract.annotation().linearizedBaseContracts; + std::vector const& bases = _contract.annotation().linearizedBaseContracts; // Determine the arguments that are used for the base constructors. for (ContractDefinition const* contract: bases) @@ -430,7 +429,7 @@ void ContractLevelChecker::annotateBaseConstructorArguments( void ContractLevelChecker::checkExternalTypeClashes(ContractDefinition const& _contract) { - map>> externalDeclarations; + std::map>> externalDeclarations; for (ContractDefinition const* contract: _contract.annotation().linearizedBaseContracts) { for (FunctionDefinition const* f: contract->definedFunctions()) @@ -467,7 +466,7 @@ void ContractLevelChecker::checkExternalTypeClashes(ContractDefinition const& _c void ContractLevelChecker::checkHashCollisions(ContractDefinition const& _contract) { - set> hashes; + std::set> hashes; for (auto const& it: _contract.interfaceFunctionList()) { util::FixedHash<4> const& hash = it.first; @@ -475,7 +474,7 @@ void ContractLevelChecker::checkHashCollisions(ContractDefinition const& _contra m_errorReporter.fatalTypeError( 1860_error, _contract.location(), - string("Function signature hash collision for ") + it.second->externalSignature() + std::string("Function signature hash collision for ") + it.second->externalSignature() ); hashes.insert(hash); } diff --git a/libsolidity/analysis/ControlFlowAnalyzer.cpp b/libsolidity/analysis/ControlFlowAnalyzer.cpp index e80964acebab..7ae1aa76e2b9 100644 --- a/libsolidity/analysis/ControlFlowAnalyzer.cpp +++ b/libsolidity/analysis/ControlFlowAnalyzer.cpp @@ -25,7 +25,6 @@ #include -using namespace std; using namespace std::placeholders; using namespace solidity::langutil; using namespace solidity::frontend; @@ -44,7 +43,7 @@ void ControlFlowAnalyzer::analyze(FunctionDefinition const& _function, ContractD if (!_function.isImplemented()) return; - optional mostDerivedContractName; + std::optional mostDerivedContractName; // The name of the most derived contract only required if it differs from // the functions contract @@ -61,13 +60,13 @@ void ControlFlowAnalyzer::analyze(FunctionDefinition const& _function, ContractD } -void ControlFlowAnalyzer::checkUninitializedAccess(CFGNode const* _entry, CFGNode const* _exit, bool _emptyBody, optional _contractName) +void ControlFlowAnalyzer::checkUninitializedAccess(CFGNode const* _entry, CFGNode const* _exit, bool _emptyBody, std::optional _contractName) { struct NodeInfo { - set unassignedVariablesAtEntry; - set unassignedVariablesAtExit; - set uninitializedVariableAccesses; + std::set unassignedVariablesAtEntry; + std::set unassignedVariablesAtExit; + std::set uninitializedVariableAccesses; /// Propagate the information from another node to this node. /// To be used to propagate information from a node to its exit nodes. /// Returns true, if new variables were added and thus the current node has @@ -84,8 +83,8 @@ void ControlFlowAnalyzer::checkUninitializedAccess(CFGNode const* _entry, CFGNod ; } }; - map nodeInfos; - set nodesToTraverse; + std::map nodeInfos; + std::set nodesToTraverse; nodesToTraverse.insert(_entry); // Walk all paths starting from the nodes in ``nodesToTraverse`` until ``NodeInfo::propagateFrom`` @@ -138,7 +137,7 @@ void ControlFlowAnalyzer::checkUninitializedAccess(CFGNode const* _entry, CFGNod auto const& exitInfo = nodeInfos[_exit]; if (!exitInfo.uninitializedVariableAccesses.empty()) { - vector uninitializedAccessesOrdered( + std::vector uninitializedAccessesOrdered( exitInfo.uninitializedVariableAccesses.begin(), exitInfo.uninitializedVariableAccesses.end() ); @@ -168,7 +167,7 @@ void ControlFlowAnalyzer::checkUninitializedAccess(CFGNode const* _entry, CFGNod varDecl.location(), ssl, "This variable is of " + - string(isStorage ? "storage" : "calldata") + + std::string(isStorage ? "storage" : "calldata") + " pointer type and can be " + (variableOccurrence->kind() == VariableOccurrence::Kind::Return ? "returned" : "accessed") + " without prior assignment, which would lead to undefined behaviour." diff --git a/libsolidity/analysis/ControlFlowBuilder.cpp b/libsolidity/analysis/ControlFlowBuilder.cpp index 1f2cfcac9dd5..c20968a14d79 100644 --- a/libsolidity/analysis/ControlFlowBuilder.cpp +++ b/libsolidity/analysis/ControlFlowBuilder.cpp @@ -21,10 +21,8 @@ #include #include -using namespace solidity; using namespace solidity::langutil; using namespace solidity::frontend; -using namespace std; ControlFlowBuilder::ControlFlowBuilder(CFG::NodeContainer& _nodeContainer, FunctionFlow const& _functionFlow, ContractDefinition const* _contract): m_nodeContainer(_nodeContainer), @@ -37,13 +35,13 @@ ControlFlowBuilder::ControlFlowBuilder(CFG::NodeContainer& _nodeContainer, Funct } -unique_ptr ControlFlowBuilder::createFunctionFlow( +std::unique_ptr ControlFlowBuilder::createFunctionFlow( CFG::NodeContainer& _nodeContainer, FunctionDefinition const& _function, ContractDefinition const* _contract ) { - auto functionFlow = make_unique(); + auto functionFlow = std::make_unique(); functionFlow->entry = _nodeContainer.newNode(); functionFlow->exit = _nodeContainer.newNode(); functionFlow->revert = _nodeContainer.newNode(); diff --git a/libsolidity/analysis/ControlFlowGraph.cpp b/libsolidity/analysis/ControlFlowGraph.cpp index 71acb8a672f0..518743ef1993 100644 --- a/libsolidity/analysis/ControlFlowGraph.cpp +++ b/libsolidity/analysis/ControlFlowGraph.cpp @@ -20,7 +20,6 @@ #include -using namespace std; using namespace solidity::langutil; using namespace solidity::frontend; diff --git a/libsolidity/analysis/DeclarationContainer.cpp b/libsolidity/analysis/DeclarationContainer.cpp index b6cd3eef01ba..df6e664baca1 100644 --- a/libsolidity/analysis/DeclarationContainer.cpp +++ b/libsolidity/analysis/DeclarationContainer.cpp @@ -29,7 +29,6 @@ #include #include -using namespace std; using namespace solidity; using namespace solidity::frontend; @@ -41,7 +40,7 @@ Declaration const* DeclarationContainer::conflictingDeclaration( if (!_name) _name = &_declaration.name(); solAssert(!_name->empty(), ""); - vector declarations; + std::vector declarations; if (m_declarations.count(*_name)) declarations += m_declarations.at(*_name); if (m_invisibleDeclarations.count(*_name)) @@ -127,7 +126,7 @@ bool DeclarationContainer::registerDeclaration( m_homonymCandidates.emplace_back(*_name, _location ? _location : &_declaration.location()); } - vector& decls = _invisible ? m_invisibleDeclarations[*_name] : m_declarations[*_name]; + std::vector& decls = _invisible ? m_invisibleDeclarations[*_name] : m_declarations[*_name]; if (!util::contains(decls, &_declaration)) decls.push_back(&_declaration); return true; @@ -142,13 +141,13 @@ bool DeclarationContainer::registerDeclaration( return registerDeclaration(_declaration, nullptr, nullptr, _invisible, _update); } -vector DeclarationContainer::resolveName( +std::vector DeclarationContainer::resolveName( ASTString const& _name, ResolvingSettings _settings ) const { solAssert(!_name.empty(), "Attempt to resolve empty name."); - vector result; + std::vector result; if (m_declarations.count(_name)) { @@ -172,24 +171,24 @@ vector DeclarationContainer::resolveName( return result; } -vector DeclarationContainer::similarNames(ASTString const& _name) const +std::vector DeclarationContainer::similarNames(ASTString const& _name) const { // because the function below has quadratic runtime - it will not magically improve once a better algorithm is discovered ;) // since 80 is the suggested line length limit, we use 80^2 as length threshold static size_t const MAXIMUM_LENGTH_THRESHOLD = 80 * 80; - vector similar; + std::vector similar; size_t maximumEditDistance = _name.size() > 3 ? 2 : _name.size() / 2; for (auto const& declaration: m_declarations) { - string const& declarationName = declaration.first; + std::string const& declarationName = declaration.first; if (util::stringWithinDistance(_name, declarationName, maximumEditDistance, MAXIMUM_LENGTH_THRESHOLD)) similar.push_back(declarationName); } for (auto const& declaration: m_invisibleDeclarations) { - string const& declarationName = declaration.first; + std::string const& declarationName = declaration.first; if (util::stringWithinDistance(_name, declarationName, maximumEditDistance, MAXIMUM_LENGTH_THRESHOLD)) similar.push_back(declarationName); } @@ -200,7 +199,7 @@ vector DeclarationContainer::similarNames(ASTString const& _name) con return similar; } -void DeclarationContainer::populateHomonyms(back_insert_iterator _it) const +void DeclarationContainer::populateHomonyms(std::back_insert_iterator _it) const { for (DeclarationContainer const* innerContainer: m_innerContainers) innerContainer->populateHomonyms(_it); @@ -210,7 +209,7 @@ void DeclarationContainer::populateHomonyms(back_insert_iterator _it) ResolvingSettings settings; settings.recursive = true; settings.alsoInvisible = true; - vector const& declarations = m_enclosingContainer->resolveName(name, std::move(settings)); + std::vector const& declarations = m_enclosingContainer->resolveName(name, std::move(settings)); if (!declarations.empty()) _it = make_pair(location, declarations); } diff --git a/libsolidity/analysis/DeclarationTypeChecker.cpp b/libsolidity/analysis/DeclarationTypeChecker.cpp index f17c854a7bff..28c051c0a000 100644 --- a/libsolidity/analysis/DeclarationTypeChecker.cpp +++ b/libsolidity/analysis/DeclarationTypeChecker.cpp @@ -29,7 +29,6 @@ #include -using namespace std; using namespace solidity::langutil; using namespace solidity::frontend; @@ -336,10 +335,10 @@ void DeclarationTypeChecker::endVisit(ArrayTypeName const& _typeName) if (Expression const* length = _typeName.length()) { - optional lengthValue; + std::optional lengthValue; if (length->annotation().type && length->annotation().type->category() == Type::Category::RationalNumber) lengthValue = dynamic_cast(*length->annotation().type).value(); - else if (optional value = ConstantEvaluator::evaluate(m_errorReporter, *length)) + else if (std::optional value = ConstantEvaluator::evaluate(m_errorReporter, *length)) lengthValue = value->value; if (!lengthValue) @@ -399,10 +398,10 @@ void DeclarationTypeChecker::endVisit(VariableDeclaration const& _variable) Location varLoc = _variable.referenceLocation(); DataLocation typeLoc = DataLocation::Memory; - set allowedDataLocations = _variable.allowedDataLocations(); + std::set allowedDataLocations = _variable.allowedDataLocations(); if (!allowedDataLocations.count(varLoc)) { - auto locationToString = [](VariableDeclaration::Location _location) -> string + auto locationToString = [](VariableDeclaration::Location _location) -> std::string { switch (_location) { @@ -414,7 +413,7 @@ void DeclarationTypeChecker::endVisit(VariableDeclaration const& _variable) return {}; }; - string errorString; + std::string errorString; if (!_variable.hasReferenceOrMappingType()) errorString = "Data location can only be specified for array, struct or mapping types"; else @@ -430,9 +429,9 @@ void DeclarationTypeChecker::endVisit(VariableDeclaration const& _variable) else if (_variable.isCallableOrCatchParameter()) errorString += " for " + - string(_variable.isReturnParameter() ? "return " : "") + + std::string(_variable.isReturnParameter() ? "return " : "") + "parameter in" + - string(_variable.isExternalCallableParameter() ? " external" : "") + + std::string(_variable.isExternalCallableParameter() ? " external" : "") + " function"; else errorString += " for variable"; diff --git a/libsolidity/analysis/DocStringAnalyser.cpp b/libsolidity/analysis/DocStringAnalyser.cpp index 5cff34f2a0ae..d4afadf26f5d 100644 --- a/libsolidity/analysis/DocStringAnalyser.cpp +++ b/libsolidity/analysis/DocStringAnalyser.cpp @@ -30,7 +30,6 @@ #include -using namespace std; using namespace solidity; using namespace solidity::langutil; using namespace solidity::frontend; @@ -38,7 +37,7 @@ using namespace solidity::frontend; namespace { -void copyMissingTags(set const& _baseFunctions, StructurallyDocumentedAnnotation& _target, FunctionType const* _functionType = nullptr) +void copyMissingTags(std::set const& _baseFunctions, StructurallyDocumentedAnnotation& _target, FunctionType const* _functionType = nullptr) { // Only copy if there is exactly one direct base function. if (_baseFunctions.size() != 1) @@ -50,7 +49,7 @@ void copyMissingTags(set const& _baseFunctions, Stru for (auto it = sourceDoc.docTags.begin(); it != sourceDoc.docTags.end();) { - string const& tag = it->first; + std::string const& tag = it->first; // Don't copy tag "inheritdoc", custom tags or already existing tags if (tag == "inheritdoc" || _target.docTags.count(tag) || boost::starts_with(tag, "custom")) { @@ -68,7 +67,7 @@ void copyMissingTags(set const& _baseFunctions, Stru if (_functionType && tag == "return") { size_t docParaNameEndPos = content.content.find_first_of(" \t"); - string const docParameterName = content.content.substr(0, docParaNameEndPos); + std::string const docParameterName = content.content.substr(0, docParaNameEndPos); if ( _functionType->returnParameterNames().size() > n && @@ -80,10 +79,10 @@ void copyMissingTags(set const& _baseFunctions, Stru baseFunction.returnParameters().size() > n && baseFunction.returnParameters().at(n)->name().empty(); - string paramName = _functionType->returnParameterNames().at(n); + std::string paramName = _functionType->returnParameterNames().at(n); content.content = (paramName.empty() ? "" : std::move(paramName) + " ") + ( - string::npos == docParaNameEndPos || baseHasNoName ? + std::string::npos == docParaNameEndPos || baseHasNoName ? content.content : content.content.substr(docParaNameEndPos + 1) ); @@ -95,7 +94,7 @@ void copyMissingTags(set const& _baseFunctions, Stru } } -CallableDeclaration const* findBaseCallable(set const& _baseFunctions, int64_t _contractId) +CallableDeclaration const* findBaseCallable(std::set const& _baseFunctions, int64_t _contractId) { for (CallableDeclaration const* baseFuncCandidate: _baseFunctions) if (baseFuncCandidate->annotation().contract->id() == _contractId) @@ -181,7 +180,7 @@ void DocStringAnalyser::handleCallable( } CallableDeclaration const* DocStringAnalyser::resolveInheritDoc( - set const& _baseFuncs, + std::set const& _baseFuncs, StructurallyDocumented const& _node, StructurallyDocumentedAnnotation& _annotation ) diff --git a/libsolidity/analysis/DocStringTagParser.cpp b/libsolidity/analysis/DocStringTagParser.cpp index 1dc2711ef1d3..5d95f42e902c 100644 --- a/libsolidity/analysis/DocStringTagParser.cpp +++ b/libsolidity/analysis/DocStringTagParser.cpp @@ -37,7 +37,6 @@ #include #include -using namespace std; using namespace solidity; using namespace solidity::langutil; using namespace solidity::frontend; @@ -67,7 +66,7 @@ bool DocStringTagParser::validateDocStringsUsingTypes(SourceUnit const& _sourceU if (tagName == "return") { returnTagsVisited++; - vector returnParameterNames; + std::vector returnParameterNames; if (auto const* varDecl = dynamic_cast(&_node)) { @@ -82,8 +81,8 @@ bool DocStringTagParser::validateDocStringsUsingTypes(SourceUnit const& _sourceU else continue; - string content = tagValue.content; - string firstWord = content.substr(0, content.find_first_of(" \t")); + std::string content = tagValue.content; + std::string firstWord = content.substr(0, content.find_first_of(" \t")); if (returnTagsVisited > returnParameterNames.size()) m_errorReporter.docstringParsingError( @@ -94,7 +93,7 @@ bool DocStringTagParser::validateDocStringsUsingTypes(SourceUnit const& _sourceU ); else { - string const& parameter = returnParameterNames.at(returnTagsVisited - 1); + std::string const& parameter = returnParameterNames.at(returnTagsVisited - 1); if (!parameter.empty() && parameter != firstWord) m_errorReporter.docstringParsingError( 5856_error, @@ -113,7 +112,7 @@ bool DocStringTagParser::validateDocStringsUsingTypes(SourceUnit const& _sourceU bool DocStringTagParser::visit(ContractDefinition const& _contract) { - static set const validTags = set{"author", "title", "dev", "notice"}; + static std::set const validTags = std::set{"author", "title", "dev", "notice"}; parseDocStrings(_contract, _contract.annotation(), validTags, "contracts"); return true; @@ -193,12 +192,12 @@ bool DocStringTagParser::visit(InlineAssembly const& _assembly) { if (tagName == "solidity") { - vector values; + std::vector values; boost::split(values, tagValue.content, isWhiteSpace); - set valuesSeen; - set duplicates; - for (auto const& value: values | ranges::views::filter(not_fn(&string::empty))) + std::set valuesSeen; + std::set duplicates; + for (auto const& value: values | ranges::views::filter(not_fn(&std::string::empty))) if (valuesSeen.insert(value).second) { if (value == "memory-safe-assembly") @@ -244,7 +243,7 @@ void DocStringTagParser::checkParameters( StructurallyDocumentedAnnotation& _annotation ) { - set validParams; + std::set validParams; for (auto const& p: _callable.parameters()) validParams.insert(p->name()); if (_callable.returnParameterList()) @@ -268,7 +267,7 @@ void DocStringTagParser::handleConstructor( StructurallyDocumentedAnnotation& _annotation ) { - static set const validTags = set{"author", "dev", "notice", "param"}; + static std::set const validTags = std::set{"author", "dev", "notice", "param"}; parseDocStrings(_node, _annotation, validTags, "constructor"); checkParameters(_callable, _node, _annotation); } @@ -279,10 +278,10 @@ void DocStringTagParser::handleCallable( StructurallyDocumentedAnnotation& _annotation ) { - static set const validEventTags = set{"dev", "notice", "return", "param"}; - static set const validErrorTags = set{"dev", "notice", "param"}; - static set const validModifierTags = set{"dev", "notice", "param", "inheritdoc"}; - static set const validTags = set{"dev", "notice", "return", "param", "inheritdoc"}; + static std::set const validEventTags = std::set{"dev", "notice", "return", "param"}; + static std::set const validErrorTags = std::set{"dev", "notice", "param"}; + static std::set const validModifierTags = std::set{"dev", "notice", "param", "inheritdoc"}; + static std::set const validTags = std::set{"dev", "notice", "return", "param", "inheritdoc"}; if (dynamic_cast(&_callable)) parseDocStrings(_node, _annotation, validEventTags, "events"); @@ -299,8 +298,8 @@ void DocStringTagParser::handleCallable( void DocStringTagParser::parseDocStrings( StructurallyDocumented const& _node, StructurallyDocumentedAnnotation& _annotation, - set const& _validTags, - string const& _nodeName + std::set const& _validTags, + std::string const& _nodeName ) { if (!_node.documentation()) @@ -310,7 +309,7 @@ void DocStringTagParser::parseDocStrings( for (auto const& [tagName, tagValue]: _annotation.docTags) { - string_view static constexpr customPrefix("custom:"); + std::string_view static constexpr customPrefix("custom:"); if (tagName == "custom" || tagName == "custom:") m_errorReporter.docstringParsingError( 6564_error, @@ -319,7 +318,7 @@ void DocStringTagParser::parseDocStrings( ); else if (boost::starts_with(tagName, customPrefix) && tagName.size() > customPrefix.size()) { - regex static const customRegex("^custom:[a-z][a-z-]*$"); + std::regex static const customRegex("^custom:[a-z][a-z-]*$"); if (!regex_match(tagName, customRegex)) m_errorReporter.docstringParsingError( 2968_error, diff --git a/libsolidity/analysis/FunctionCallGraph.cpp b/libsolidity/analysis/FunctionCallGraph.cpp index ce5c539346b5..1d01f1a6bced 100644 --- a/libsolidity/analysis/FunctionCallGraph.cpp +++ b/libsolidity/analysis/FunctionCallGraph.cpp @@ -24,7 +24,6 @@ #include #include -using namespace std; using namespace solidity::frontend; using namespace solidity::util; @@ -72,7 +71,7 @@ CallGraph FunctionCallGraphBuilder::buildDeployedGraph( FunctionCallGraphBuilder builder(_contract); solAssert(builder.m_currentNode == CallGraph::Node(CallGraph::SpecialNode::Entry), ""); - auto getSecondElement = [](auto const& _tuple){ return get<1>(_tuple); }; + auto getSecondElement = [](auto const& _tuple){ return std::get<1>(_tuple); }; // Create graph for all publicly reachable functions for (FunctionTypePointer functionType: _contract.interfaceFunctionList() | ranges::views::transform(getSecondElement)) @@ -96,14 +95,14 @@ CallGraph FunctionCallGraphBuilder::buildDeployedGraph( // All functions present in internal dispatch at creation time could potentially be pointers // assigned to state variables and as such may be reachable after deployment as well. builder.m_currentNode = CallGraph::SpecialNode::InternalDispatch; - set defaultNode; + std::set defaultNode; for (CallGraph::Node const& dispatchTarget: util::valueOrDefault(_creationGraph.edges, CallGraph::SpecialNode::InternalDispatch, defaultNode)) { - solAssert(!holds_alternative(dispatchTarget), ""); - solAssert(get(dispatchTarget) != nullptr, ""); + solAssert(!std::holds_alternative(dispatchTarget), ""); + solAssert(std::get(dispatchTarget) != nullptr, ""); // Visit the callable to add not only it but also everything it calls too - builder.functionReferenced(*get(dispatchTarget), false); + builder.functionReferenced(*std::get(dispatchTarget), false); } builder.m_currentNode = CallGraph::SpecialNode::Entry; @@ -262,10 +261,10 @@ void FunctionCallGraphBuilder::processQueue() while (!m_visitQueue.empty()) { m_currentNode = m_visitQueue.front(); - solAssert(holds_alternative(m_currentNode), ""); + solAssert(std::holds_alternative(m_currentNode), ""); m_visitQueue.pop_front(); - get(m_currentNode)->accept(*this); + std::get(m_currentNode)->accept(*this); } m_currentNode = CallGraph::SpecialNode::Entry; @@ -281,7 +280,7 @@ void FunctionCallGraphBuilder::functionReferenced(CallableDeclaration const& _ca if (_calledDirectly) { solAssert( - holds_alternative(m_currentNode) || m_graph.edges.count(m_currentNode) > 0, + std::holds_alternative(m_currentNode) || m_graph.edges.count(m_currentNode) > 0, "Adding an edge from a node that has not been visited yet." ); @@ -293,10 +292,10 @@ void FunctionCallGraphBuilder::functionReferenced(CallableDeclaration const& _ca enqueueCallable(_callable); } -ostream& solidity::frontend::operator<<(ostream& _out, CallGraph::Node const& _node) +std::ostream& solidity::frontend::operator<<(std::ostream& _out, CallGraph::Node const& _node) { - if (holds_alternative(_node)) - switch (get(_node)) + if (std::holds_alternative(_node)) + switch (std::get(_node)) { case CallGraph::SpecialNode::InternalDispatch: _out << "InternalDispatch"; @@ -309,19 +308,19 @@ ostream& solidity::frontend::operator<<(ostream& _out, CallGraph::Node const& _n } else { - solAssert(holds_alternative(_node), ""); + solAssert(std::holds_alternative(_node), ""); - auto const* callableDeclaration = get(_node); + auto const* callableDeclaration = std::get(_node); solAssert(callableDeclaration, ""); auto const* function = dynamic_cast(callableDeclaration); auto const* event = dynamic_cast(callableDeclaration); auto const* modifier = dynamic_cast(callableDeclaration); - auto typeToString = [](auto const& _var) -> string { return _var->type()->toString(true); }; - vector parameters = callableDeclaration->parameters() | ranges::views::transform(typeToString) | ranges::to>(); + auto typeToString = [](auto const& _var) -> std::string { return _var->type()->toString(true); }; + std::vector parameters = callableDeclaration->parameters() | ranges::views::transform(typeToString) | ranges::to>(); - string scopeName; + std::string scopeName; if (!function || !function->isFree()) { solAssert(callableDeclaration->annotation().scope, ""); diff --git a/libsolidity/analysis/GlobalContext.cpp b/libsolidity/analysis/GlobalContext.cpp index 58ebea7b1ae7..8f0ce963499b 100644 --- a/libsolidity/analysis/GlobalContext.cpp +++ b/libsolidity/analysis/GlobalContext.cpp @@ -29,8 +29,6 @@ #include #include -using namespace std; - namespace solidity::frontend { @@ -65,10 +63,10 @@ int magicVariableToID(std::string const& _name) solAssert(false, "Unknown magic variable: \"" + _name + "\"."); } -inline vector> constructMagicVariables() +inline std::vector> constructMagicVariables() { - static auto const magicVarDecl = [](string const& _name, Type const* _type) { - return make_shared(magicVariableToID(_name), _name, _type); + static auto const magicVarDecl = [](std::string const& _name, Type const* _type) { + return std::make_shared(magicVariableToID(_name), _name, _type); }; return { @@ -116,9 +114,9 @@ void GlobalContext::setCurrentContract(ContractDefinition const& _contract) m_currentContract = &_contract; } -vector GlobalContext::declarations() const +std::vector GlobalContext::declarations() const { - vector declarations; + std::vector declarations; declarations.reserve(m_magicVariables.size()); for (ASTPointer const& variable: m_magicVariables) declarations.push_back(variable.get()); @@ -133,7 +131,7 @@ MagicVariableDeclaration const* GlobalContext::currentThis() const if (m_currentContract) type = TypeProvider::contract(*m_currentContract); m_thisPointer[m_currentContract] = - make_shared(magicVariableToID("this"), "this", type); + std::make_shared(magicVariableToID("this"), "this", type); } return m_thisPointer[m_currentContract].get(); } @@ -146,7 +144,7 @@ MagicVariableDeclaration const* GlobalContext::currentSuper() const if (m_currentContract) type = TypeProvider::typeType(TypeProvider::contract(*m_currentContract, true)); m_superPointer[m_currentContract] = - make_shared(magicVariableToID("super"), "super", type); + std::make_shared(magicVariableToID("super"), "super", type); } return m_superPointer[m_currentContract].get(); } diff --git a/libsolidity/analysis/NameAndTypeResolver.cpp b/libsolidity/analysis/NameAndTypeResolver.cpp index 641f02280430..d6ff63dbf34f 100644 --- a/libsolidity/analysis/NameAndTypeResolver.cpp +++ b/libsolidity/analysis/NameAndTypeResolver.cpp @@ -30,7 +30,6 @@ #include #include -using namespace std; using namespace solidity::langutil; namespace solidity::frontend @@ -45,7 +44,7 @@ NameAndTypeResolver::NameAndTypeResolver( m_errorReporter(_errorReporter), m_globalContext(_globalContext) { - m_scopes[nullptr] = make_shared(); + m_scopes[nullptr] = std::make_shared(); for (Declaration const* declaration: _globalContext.declarations()) { solAssert(m_scopes[nullptr]->registerDeclaration(*declaration, false, false), "Unable to register global declaration."); @@ -68,14 +67,14 @@ bool NameAndTypeResolver::registerDeclarations(SourceUnit& _sourceUnit, ASTNode return true; } -bool NameAndTypeResolver::performImports(SourceUnit& _sourceUnit, map const& _sourceUnits) +bool NameAndTypeResolver::performImports(SourceUnit& _sourceUnit, std::map const& _sourceUnits) { DeclarationContainer& target = *m_scopes.at(&_sourceUnit); bool error = false; for (auto const& node: _sourceUnit.nodes()) if (auto imp = dynamic_cast(node.get())) { - string const& path = *imp->annotation().absolutePath; + std::string const& path = *imp->annotation().absolutePath; // The import resolution in CompilerStack enforces this. solAssert(_sourceUnits.count(path), ""); auto scope = m_scopes.find(_sourceUnits.at(path)); @@ -127,7 +126,7 @@ bool NameAndTypeResolver::resolveNamesAndTypes(SourceUnit& _source) { try { - for (shared_ptr const& node: _source.nodes()) + for (std::shared_ptr const& node: _source.nodes()) { setScope(&_source); if (!resolveNamesAndTypesInternal(*node, true)) @@ -159,7 +158,7 @@ bool NameAndTypeResolver::updateDeclaration(Declaration const& _declaration) return true; } -void NameAndTypeResolver::activateVariable(string const& _name) +void NameAndTypeResolver::activateVariable(std::string const& _name) { solAssert(m_currentScope, ""); // Scoped local variables are invisible before activation. @@ -171,15 +170,15 @@ void NameAndTypeResolver::activateVariable(string const& _name) m_currentScope->activateVariable(_name); } -vector NameAndTypeResolver::resolveName(ASTString const& _name, ASTNode const* _scope) const +std::vector NameAndTypeResolver::resolveName(ASTString const& _name, ASTNode const* _scope) const { auto iterator = m_scopes.find(_scope); if (iterator == end(m_scopes)) - return vector({}); + return std::vector({}); return iterator->second->resolveName(_name); } -vector NameAndTypeResolver::nameFromCurrentScope(ASTString const& _name, bool _includeInvisibles) const +std::vector NameAndTypeResolver::nameFromCurrentScope(ASTString const& _name, bool _includeInvisibles) const { ResolvingSettings settings; settings.recursive = true; @@ -187,7 +186,7 @@ vector NameAndTypeResolver::nameFromCurrentScope(ASTString c return m_currentScope->resolveName(_name, std::move(settings)); } -Declaration const* NameAndTypeResolver::pathFromCurrentScope(vector const& _path) const +Declaration const* NameAndTypeResolver::pathFromCurrentScope(std::vector const& _path) const { if (auto declarations = pathFromCurrentScopeWithAllDeclarations(_path); !declarations.empty()) return declarations.back(); @@ -201,13 +200,13 @@ std::vector NameAndTypeResolver::pathFromCurrentScopeWithAll ) const { solAssert(!_path.empty(), ""); - vector pathDeclarations; + std::vector pathDeclarations; ResolvingSettings settings; settings.recursive = true; settings.alsoInvisible = _includeInvisibles; settings.onlyVisibleAsUnqualifiedNames = true; - vector candidates = m_currentScope->resolveName(_path.front(), settings); + std::vector candidates = m_currentScope->resolveName(_path.front(), settings); // inside the loop, use default settings, except for alsoInvisible settings.recursive = false; @@ -305,7 +304,7 @@ bool NameAndTypeResolver::resolveNamesAndTypesInternal(ASTNode& _node, bool _res if (success) { linearizeBaseContracts(*contract); - vector properBases( + std::vector properBases( ++contract->annotation().linearizedBaseContracts.begin(), contract->annotation().linearizedBaseContracts.end() ); @@ -405,7 +404,7 @@ void NameAndTypeResolver::linearizeBaseContracts(ContractDefinition& _contract) { // order in the lists is from derived to base // list of lists to linearize, the last element is the list of direct bases - list> input(1, list{}); + std::list> input(1, std::list{}); for (ASTPointer const& baseSpecifier: _contract.baseContracts()) { IdentifierPath const& baseName = baseSpecifier->name(); @@ -415,25 +414,25 @@ void NameAndTypeResolver::linearizeBaseContracts(ContractDefinition& _contract) // "push_front" has the effect that bases mentioned later can overwrite members of bases // mentioned earlier input.back().push_front(base); - vector const& basesBases = base->annotation().linearizedBaseContracts; + std::vector const& basesBases = base->annotation().linearizedBaseContracts; if (basesBases.empty()) m_errorReporter.fatalTypeError(2449_error, baseName.location(), "Definition of base has to precede definition of derived contract"); - input.push_front(list(basesBases.begin(), basesBases.end())); + input.push_front(std::list(basesBases.begin(), basesBases.end())); } input.back().push_front(&_contract); - vector result = cThreeMerge(input); + std::vector result = cThreeMerge(input); if (result.empty()) m_errorReporter.fatalTypeError(5005_error, _contract.location(), "Linearization of inheritance graph impossible"); _contract.annotation().linearizedBaseContracts = result; } template -vector NameAndTypeResolver::cThreeMerge(list>& _toMerge) +std::vector NameAndTypeResolver::cThreeMerge(std::list>& _toMerge) { // returns true iff _candidate appears only as last element of the lists auto appearsOnlyAtHead = [&](T const* _candidate) -> bool { - for (list const& bases: _toMerge) + for (std::list const& bases: _toMerge) { solAssert(!bases.empty(), ""); if (find(++bases.begin(), bases.end(), _candidate) != bases.end()) @@ -444,7 +443,7 @@ vector NameAndTypeResolver::cThreeMerge(list>& _toMerge // returns the next candidate to append to the linearized list or nullptr on failure auto nextCandidate = [&]() -> T const* { - for (list const& bases: _toMerge) + for (std::list const& bases: _toMerge) { solAssert(!bases.empty(), ""); if (appearsOnlyAtHead(bases.front())) @@ -465,26 +464,26 @@ vector NameAndTypeResolver::cThreeMerge(list>& _toMerge } }; - _toMerge.remove_if([](list const& _bases) { return _bases.empty(); }); - vector result; + _toMerge.remove_if([](std::list const& _bases) { return _bases.empty(); }); + std::vector result; while (!_toMerge.empty()) { T const* candidate = nextCandidate(); if (!candidate) - return vector(); + return std::vector(); result.push_back(candidate); removeCandidate(candidate); } return result; } -string NameAndTypeResolver::similarNameSuggestions(ASTString const& _name) const + std::string NameAndTypeResolver::similarNameSuggestions(ASTString const& _name) const { return util::quotedAlternativesList(m_currentScope->similarNames(_name)); } DeclarationRegistrationHelper::DeclarationRegistrationHelper( - map>& _scopes, + std::map>& _scopes, ASTNode& _astRoot, ErrorReporter& _errorReporter, GlobalContext& _globalContext, @@ -502,7 +501,7 @@ DeclarationRegistrationHelper::DeclarationRegistrationHelper( bool DeclarationRegistrationHelper::registerDeclaration( DeclarationContainer& _container, Declaration const& _declaration, - string const* _name, + std::string const* _name, SourceLocation const* _errorLocation, bool _inactive, ErrorReporter& _errorReporter @@ -511,13 +510,13 @@ bool DeclarationRegistrationHelper::registerDeclaration( if (!_errorLocation) _errorLocation = &_declaration.location(); - string name = _name ? *_name : _declaration.name(); + std::string name = _name ? *_name : _declaration.name(); // We use "invisible" for both inactive variables in blocks and for members invisible in contracts. // They cannot both be true at the same time. solAssert(!(_inactive && !_declaration.isVisibleInContract()), ""); - static set illegalNames{"_", "super", "this"}; + static std::set illegalNames{"_", "super", "this"}; if (illegalNames.count(name)) { @@ -580,7 +579,7 @@ bool DeclarationRegistrationHelper::visit(SourceUnit& _sourceUnit) { if (!m_scopes[&_sourceUnit]) // By importing, it is possible that the container already exists. - m_scopes[&_sourceUnit] = make_shared(m_currentScope, m_scopes[m_currentScope].get()); + m_scopes[&_sourceUnit] = std::make_shared(m_currentScope, m_scopes[m_currentScope].get()); return ASTVisitor::visit(_sourceUnit); } @@ -594,7 +593,7 @@ bool DeclarationRegistrationHelper::visit(ImportDirective& _import) SourceUnit const* importee = _import.annotation().sourceUnit; solAssert(!!importee, ""); if (!m_scopes[importee]) - m_scopes[importee] = make_shared(nullptr, m_scopes[nullptr].get()); + m_scopes[importee] = std::make_shared(nullptr, m_scopes[nullptr].get()); m_scopes[&_import] = m_scopes[importee]; ASTVisitor::visit(_import); return false; // Do not recurse into child nodes (Identifier for symbolAliases) @@ -641,7 +640,7 @@ bool DeclarationRegistrationHelper::visitNode(ASTNode& _node) if (auto* annotation = dynamic_cast(&_node.annotation())) { - string canonicalName = dynamic_cast(_node).name(); + std::string canonicalName = dynamic_cast(_node).name(); solAssert(!canonicalName.empty(), ""); for ( @@ -684,7 +683,7 @@ void DeclarationRegistrationHelper::enterNewSubScope(ASTNode& _subScope) { bool newlyAdded = m_scopes.emplace( &_subScope, - make_shared(m_currentScope, m_scopes[m_currentScope].get()) + std::make_shared(m_currentScope, m_scopes[m_currentScope].get()) ).second; solAssert(newlyAdded, "Unable to add new scope."); } diff --git a/libsolidity/analysis/OverrideChecker.cpp b/libsolidity/analysis/OverrideChecker.cpp index d342ab100359..f2a99340deee 100644 --- a/libsolidity/analysis/OverrideChecker.cpp +++ b/libsolidity/analysis/OverrideChecker.cpp @@ -31,7 +31,6 @@ #include -using namespace std; using namespace solidity; using namespace solidity::frontend; using namespace solidity::langutil; @@ -46,7 +45,7 @@ namespace // Helper struct to do a search by name struct MatchByName { - string const& m_name; + std::string const& m_name; bool operator()(OverrideProxy const& _item) { return _item.name() == m_name; @@ -61,7 +60,7 @@ struct MatchByName */ struct OverrideGraph { - OverrideGraph(set const& _baseCallables) + OverrideGraph(std::set const& _baseCallables) { for (auto const& baseFunction: _baseCallables) addEdge(0, visit(baseFunction)); @@ -131,17 +130,17 @@ struct CutVertexFinder run(vInd, _depth + 1); if (m_low[vInd] >= m_depths[_u] && m_parent[_u] != -1) m_cutVertices.insert(m_graph.nodeInv.at(static_cast(_u))); - m_low[_u] = min(m_low[_u], m_low[vInd]); + m_low[_u] = std::min(m_low[_u], m_low[vInd]); } else if (v != m_parent[_u]) - m_low[_u] = min(m_low[_u], m_depths[vInd]); + m_low[_u] = std::min(m_low[_u], m_depths[vInd]); } } }; -vector resolveDirectBaseContracts(ContractDefinition const& _contract) +std::vector resolveDirectBaseContracts(ContractDefinition const& _contract) { - vector resolvedContracts; + std::vector resolvedContracts; for (ASTPointer const& specifier: _contract.baseContracts()) { @@ -155,7 +154,7 @@ vector resolveDirectBaseContracts(ContractDefinition return resolvedContracts; } -vector> sortByContract(vector> const& _list) +std::vector> sortByContract(std::vector> const& _list) { auto sorted = _list; @@ -197,17 +196,17 @@ bool OverrideProxy::operator<(OverrideProxy const& _other) const bool OverrideProxy::isVariable() const { - return holds_alternative(m_item); + return std::holds_alternative(m_item); } bool OverrideProxy::isFunction() const { - return holds_alternative(m_item); + return std::holds_alternative(m_item); } bool OverrideProxy::isModifier() const { - return holds_alternative(m_item); + return std::holds_alternative(m_item); } bool OverrideProxy::CompareBySignature::operator()(OverrideProxy const& _a, OverrideProxy const& _b) const @@ -222,18 +221,18 @@ size_t OverrideProxy::id() const }, m_item); } -shared_ptr OverrideProxy::overrides() const +std::shared_ptr OverrideProxy::overrides() const { return std::visit(GenericVisitor{ [&](auto const* _item) { return _item->overrides(); } }, m_item); } -set OverrideProxy::baseFunctions() const +std::set OverrideProxy::baseFunctions() const { return std::visit(GenericVisitor{ - [&](auto const* _item) -> set { - set ret; + [&](auto const* _item) -> std::set { + std::set ret; for (auto const* f: _item->annotation().baseFunctions) ret.insert(makeOverrideProxy(*f)); return ret; @@ -256,10 +255,10 @@ void OverrideProxy::storeBaseFunction(OverrideProxy const& _base) const }, m_item); } -string const& OverrideProxy::name() const +std::string const& OverrideProxy::name() const { return std::visit(GenericVisitor{ - [&](auto const* _item) -> string const& { return _item->name(); } + [&](auto const* _item) -> std::string const& { return _item->name(); } }, m_item); } @@ -272,7 +271,7 @@ ContractDefinition const& OverrideProxy::contract() const }, m_item); } -string const& OverrideProxy::contractName() const +std::string const& OverrideProxy::contractName() const { return contract().name(); } @@ -357,7 +356,7 @@ SourceLocation const& OverrideProxy::location() const }, m_item); } -string OverrideProxy::astNodeName() const +std::string OverrideProxy::astNodeName() const { return std::visit(GenericVisitor{ [&](FunctionDefinition const*) { return "function"; }, @@ -366,7 +365,7 @@ string OverrideProxy::astNodeName() const }, m_item); } -string OverrideProxy::astNodeNameCapitalized() const +std::string OverrideProxy::astNodeNameCapitalized() const { return std::visit(GenericVisitor{ [&](FunctionDefinition const*) { return "Function"; }, @@ -375,7 +374,7 @@ string OverrideProxy::astNodeNameCapitalized() const }, m_item); } -string OverrideProxy::distinguishingProperty() const +std::string OverrideProxy::distinguishingProperty() const { return std::visit(GenericVisitor{ [&](FunctionDefinition const*) { return "name and parameter types"; }, @@ -418,10 +417,10 @@ OverrideProxy::OverrideComparator const& OverrideProxy::overrideComparator() con { if (!m_comparator) { - m_comparator = make_shared(std::visit(GenericVisitor{ + m_comparator = std::make_shared(std::visit(GenericVisitor{ [&](FunctionDefinition const* _function) { - vector paramTypes; + std::vector paramTypes; for (Type const* t: externalFunctionType()->parameterTypes()) paramTypes.emplace_back(t->richIdentifier()); return OverrideComparator{ @@ -432,7 +431,7 @@ OverrideProxy::OverrideComparator const& OverrideProxy::overrideComparator() con }, [&](VariableDeclaration const* _var) { - vector paramTypes; + std::vector paramTypes; for (Type const* t: externalFunctionType()->parameterTypes()) paramTypes.emplace_back(t->richIdentifier()); return OverrideComparator{ @@ -674,21 +673,21 @@ void OverrideChecker::checkOverride(OverrideProxy const& _overriding, OverridePr void OverrideChecker::overrideListError( OverrideProxy const& _item, - set _secondary, + std::set _secondary, ErrorId _error, - string const& _message1, - string const& _message2 + std::string const& _message1, + std::string const& _message2 ) { // Using a set rather than a vector so the order is always the same - set names; + std::set names; SecondarySourceLocation ssl; for (Declaration const* c: _secondary) { ssl.append("This contract: ", c->location()); names.insert("\"" + c->name() + "\""); } - string contractSingularPlural = "contract "; + std::string contractSingularPlural = "contract "; if (_secondary.size() > 1) contractSingularPlural = "contracts "; @@ -708,8 +707,8 @@ void OverrideChecker::overrideError( OverrideProxy const& _overriding, OverrideProxy const& _super, ErrorId _error, - string const& _message, - optional const& _secondaryMsg + std::string const& _message, + std::optional const& _secondaryMsg ) { m_errorReporter.typeError( @@ -766,7 +765,7 @@ void OverrideChecker::checkAmbiguousOverrides(ContractDefinition const& _contrac } } -void OverrideChecker::checkAmbiguousOverridesInternal(set _baseCallables, SourceLocation const& _location) const +void OverrideChecker::checkAmbiguousOverridesInternal(std::set _baseCallables, SourceLocation const& _location) const { if (_baseCallables.size() <= 1) return; @@ -799,17 +798,17 @@ void OverrideChecker::checkAmbiguousOverridesInternal(set _baseCa for (OverrideProxy const& baseFunction: _baseCallables) ssl.append("Definition in \"" + baseFunction.contractName() + "\": ", baseFunction.location()); - string callableName = _baseCallables.begin()->astNodeName(); + std::string callableName = _baseCallables.begin()->astNodeName(); if (_baseCallables.begin()->isVariable()) callableName = "function"; - string distinguishigProperty = _baseCallables.begin()->distinguishingProperty(); + std::string distinguishigProperty = _baseCallables.begin()->distinguishingProperty(); bool foundVariable = false; for (auto const& base: _baseCallables) if (base.isVariable()) foundVariable = true; - string message = + std::string message = "Derived contract must override " + callableName + " \"" + _baseCallables.begin()->name() + "\". Two or more base classes define " + callableName + " with same " + distinguishigProperty + "."; @@ -822,9 +821,9 @@ void OverrideChecker::checkAmbiguousOverridesInternal(set _baseCa m_errorReporter.typeError(6480_error, _location, ssl, message); } -set OverrideChecker::resolveOverrideList(OverrideSpecifier const& _overrides) const +std::set OverrideChecker::resolveOverrideList(OverrideSpecifier const& _overrides) const { - set resolved; + std::set resolved; for (ASTPointer const& override: _overrides.overrides()) { @@ -842,7 +841,7 @@ set OverrideChecker::re void OverrideChecker::checkOverrideList(OverrideProxy _item, OverrideProxyBySignatureMultiSet const& _inherited) { - set specifiedContracts = + std::set specifiedContracts = _item.overrides() ? resolveOverrideList(*_item.overrides()) : decltype(specifiedContracts){}; @@ -851,7 +850,7 @@ void OverrideChecker::checkOverrideList(OverrideProxy _item, OverrideProxyBySign if (_item.overrides() && specifiedContracts.size() != _item.overrides()->overrides().size()) { // Sort by contract id to find duplicate for error reporting - vector> list = + std::vector> list = sortByContract(_item.overrides()->overrides()); // Find duplicates and output error @@ -880,7 +879,7 @@ void OverrideChecker::checkOverrideList(OverrideProxy _item, OverrideProxyBySign } } - set expectedContracts; + std::set expectedContracts; // Build list of expected contracts for (auto [begin, end] = _inherited.equal_range(_item); begin != end; begin++) @@ -898,7 +897,7 @@ void OverrideChecker::checkOverrideList(OverrideProxy _item, OverrideProxyBySign _item.astNodeNameCapitalized() + " has override specified but does not override anything." ); - set missingContracts; + std::set missingContracts; // If we expect only one contract, no contract needs to be specified if (expectedContracts.size() > 1) missingContracts = expectedContracts - specifiedContracts; @@ -931,7 +930,7 @@ OverrideChecker::OverrideProxyBySignatureMultiSet const& OverrideChecker::inheri for (auto const* base: resolveDirectBaseContracts(_contract)) { - set functionsInBase; + std::set functionsInBase; for (FunctionDefinition const* fun: base->definedFunctions()) if (!fun->isConstructor()) functionsInBase.emplace(OverrideProxy{fun}); @@ -960,7 +959,7 @@ OverrideChecker::OverrideProxyBySignatureMultiSet const& OverrideChecker::inheri for (auto const* base: resolveDirectBaseContracts(_contract)) { - set modifiersInBase; + std::set modifiersInBase; for (ModifierDefinition const* mod: base->functionModifiers()) modifiersInBase.emplace(OverrideProxy{mod}); diff --git a/libsolidity/analysis/PostTypeChecker.cpp b/libsolidity/analysis/PostTypeChecker.cpp index c8b3b5f162b2..bc9df3dc4c82 100644 --- a/libsolidity/analysis/PostTypeChecker.cpp +++ b/libsolidity/analysis/PostTypeChecker.cpp @@ -27,7 +27,6 @@ #include -using namespace std; using namespace solidity; using namespace solidity::langutil; using namespace solidity::frontend; @@ -204,7 +203,7 @@ struct ConstStateVarCircularReferenceChecker: public PostTypeChecker::Checker // Iterating through the dependencies needs to be deterministic and thus cannot // depend on the memory layout. // Because of that, we sort by AST node id. - vector dependencies( + std::vector dependencies( m_constVariableDependencies[&_variable].begin(), m_constVariableDependencies[&_variable].end() ); @@ -427,10 +426,10 @@ struct ReservedErrorSelector: public PostTypeChecker::Checker PostTypeChecker::PostTypeChecker(langutil::ErrorReporter& _errorReporter): m_errorReporter(_errorReporter) { - m_checkers.push_back(make_shared(_errorReporter)); - m_checkers.push_back(make_shared(_errorReporter)); - m_checkers.push_back(make_shared(_errorReporter)); - m_checkers.push_back(make_shared(_errorReporter)); - m_checkers.push_back(make_shared(_errorReporter)); - m_checkers.push_back(make_shared(_errorReporter)); + m_checkers.push_back(std::make_shared(_errorReporter)); + m_checkers.push_back(std::make_shared(_errorReporter)); + m_checkers.push_back(std::make_shared(_errorReporter)); + m_checkers.push_back(std::make_shared(_errorReporter)); + m_checkers.push_back(std::make_shared(_errorReporter)); + m_checkers.push_back(std::make_shared(_errorReporter)); } diff --git a/libsolidity/analysis/PostTypeContractLevelChecker.cpp b/libsolidity/analysis/PostTypeContractLevelChecker.cpp index 67d0623aa04f..6d8dc416aa00 100644 --- a/libsolidity/analysis/PostTypeContractLevelChecker.cpp +++ b/libsolidity/analysis/PostTypeContractLevelChecker.cpp @@ -26,7 +26,6 @@ #include #include -using namespace std; using namespace solidity; using namespace solidity::langutil; using namespace solidity::frontend; @@ -48,10 +47,10 @@ bool PostTypeContractLevelChecker::check(ContractDefinition const& _contract) "" ); - map> errorHashes; + std::map> errorHashes; for (ErrorDefinition const* error: _contract.interfaceErrors()) { - string signature = error->functionType(true)->externalSignature(); + std::string signature = error->functionType(true)->externalSignature(); uint32_t hash = util::selectorFromSignatureU32(signature); // Fail if there is a different signature for the same hash. if (!errorHashes[hash].empty() && !errorHashes[hash].count(signature)) diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp index 399c15b56e36..e680021331a2 100644 --- a/libsolidity/analysis/ReferencesResolver.cpp +++ b/libsolidity/analysis/ReferencesResolver.cpp @@ -39,7 +39,6 @@ #include #include -using namespace std; using namespace solidity; using namespace solidity::langutil; using namespace solidity::frontend; @@ -121,8 +120,8 @@ bool ReferencesResolver::visit(Identifier const& _identifier) auto declarations = m_resolver.nameFromCurrentScope(_identifier.name()); if (declarations.empty()) { - string suggestions = m_resolver.similarNameSuggestions(_identifier.name()); - string errorMessage = "Undeclared identifier."; + std::string suggestions = m_resolver.similarNameSuggestions(_identifier.name()); + std::string errorMessage = "Undeclared identifier."; if (!suggestions.empty()) { if ("\"" + _identifier.name() + "\"" == suggestions) @@ -192,10 +191,10 @@ bool ReferencesResolver::visit(UsingForDirective const& _usingFor) // _includeInvisibles is enabled here because external library functions are marked invisible. // As unintended side-effects other invisible names (eg.: super, this) may be returned as well. // DeclarationTypeChecker should detect and report such situations. - vector declarations = m_resolver.pathFromCurrentScopeWithAllDeclarations(path->path(), true /* _includeInvisibles */); + std::vector declarations = m_resolver.pathFromCurrentScopeWithAllDeclarations(path->path(), true /* _includeInvisibles */); if (declarations.empty()) { - string libraryOrFunctionNameErrorMessage = + std::string libraryOrFunctionNameErrorMessage = _usingFor.usesBraces() ? "Identifier is not a function name or not unique." : "Identifier is not a library name."; @@ -253,9 +252,9 @@ void ReferencesResolver::operator()(yul::Identifier const& _identifier) { solAssert(nativeLocationOf(_identifier) == originLocationOf(_identifier), ""); - static set suffixes{"slot", "offset", "length", "address", "selector"}; - string suffix; - for (string const& s: suffixes) + static std::set suffixes{"slot", "offset", "length", "address", "selector"}; + std::string suffix; + for (std::string const& s: suffixes) if (boost::algorithm::ends_with(_identifier.name.str(), "." + s)) suffix = s; @@ -269,7 +268,7 @@ void ReferencesResolver::operator()(yul::Identifier const& _identifier) if (!declarations.empty()) // the special identifier exists itself, we should not allow that. return; - string realName = _identifier.name.str().substr(0, _identifier.name.str().size() - suffix.size() - 1); + std::string realName = _identifier.name.str().substr(0, _identifier.name.str().size() - suffix.size() - 1); solAssert(!realName.empty(), "Empty name."); declarations = m_resolver.nameFromCurrentScope(realName); if (!declarations.empty()) @@ -350,7 +349,7 @@ void ReferencesResolver::resolveInheritDoc(StructuredDocumentation const& _docum break; case 1: { - string const& name = _annotation.docTags.find("inheritdoc")->second.content; + std::string const& name = _annotation.docTags.find("inheritdoc")->second.content; if (name.empty()) { m_errorReporter.docstringParsingError( @@ -361,7 +360,7 @@ void ReferencesResolver::resolveInheritDoc(StructuredDocumentation const& _docum return; } - vector path; + std::vector path; boost::split(path, name, boost::is_any_of(".")); if (any_of(path.begin(), path.end(), [](auto& _str) { return _str.empty(); })) { @@ -421,7 +420,7 @@ void ReferencesResolver::validateYulIdentifierName(yul::YulString _name, SourceL "User-defined identifiers in inline assembly cannot contain '.'." ); - if (set{"this", "super", "_"}.count(_name.str())) + if (std::set{"this", "super", "_"}.count(_name.str())) m_errorReporter.declarationError( 4113_error, _location, diff --git a/libsolidity/analysis/Scoper.cpp b/libsolidity/analysis/Scoper.cpp index 98716cf0f867..a14ca4559751 100644 --- a/libsolidity/analysis/Scoper.cpp +++ b/libsolidity/analysis/Scoper.cpp @@ -20,7 +20,6 @@ #include -using namespace std; using namespace solidity; using namespace solidity::frontend; diff --git a/libsolidity/analysis/StaticAnalyzer.cpp b/libsolidity/analysis/StaticAnalyzer.cpp index 01ca601f1222..10c2c922ca47 100644 --- a/libsolidity/analysis/StaticAnalyzer.cpp +++ b/libsolidity/analysis/StaticAnalyzer.cpp @@ -28,7 +28,6 @@ #include #include -using namespace std; using namespace solidity; using namespace solidity::langutil; using namespace solidity::frontend; @@ -71,7 +70,7 @@ class solidity::frontend::ConstructorUsesAssembly return m_usesAssembly[&_contract]; } - map m_usesAssembly; + std::map m_usesAssembly; }; StaticAnalyzer::StaticAnalyzer(ErrorReporter& _errorReporter): @@ -124,7 +123,7 @@ void StaticAnalyzer::endVisit(FunctionDefinition const&) 5667_error, var.first.second->location(), "Unused " + - string(var.first.second->isTryCatchParameter() ? "try/catch" : "function") + + std::string(var.first.second->isTryCatchParameter() ? "try/catch" : "function") + " parameter. Remove or comment out the variable name to silence this warning." ); else @@ -142,7 +141,7 @@ bool StaticAnalyzer::visit(Identifier const& _identifier) { solAssert(!var->name().empty(), ""); if (var->isLocalVariable()) - m_localVarUseCount[make_pair(var->id(), var)] += 1; + m_localVarUseCount[std::make_pair(var->id(), var)] += 1; } return true; } @@ -154,7 +153,7 @@ bool StaticAnalyzer::visit(VariableDeclaration const& _variable) solAssert(_variable.isLocalVariable(), ""); if (_variable.name() != "") // This is not a no-op, the entry might pre-exist. - m_localVarUseCount[make_pair(_variable.id(), &_variable)] += 0; + m_localVarUseCount[std::make_pair(_variable.id(), &_variable)] += 0; } if (_variable.isStateVariable() || _variable.referenceLocation() == VariableDeclaration::Location::Storage) @@ -162,7 +161,7 @@ bool StaticAnalyzer::visit(VariableDeclaration const& _variable) for (Type const* type: varType->fullDecomposition()) if (type->storageSizeUpperBound() >= (bigint(1) << 64)) { - string message = "Type " + type->toString(true) + + std::string message = "Type " + type->toString(true) + " covers a large part of storage and thus makes collisions likely." " Either use mappings or dynamic arrays and allow their size to be increased only" " in small quantities per transaction."; @@ -179,7 +178,7 @@ bool StaticAnalyzer::visit(Return const& _return) if (m_currentFunction && _return.expression()) for (auto const& var: m_currentFunction->returnParameters()) if (!var->name().empty()) - m_localVarUseCount[make_pair(var->id(), var.get())] += 1; + m_localVarUseCount[std::make_pair(var->id(), var.get())] += 1; return true; } @@ -214,7 +213,7 @@ bool StaticAnalyzer::visit(MemberAccess const& _memberAccess) else if (type->kind() == MagicType::Kind::MetaType && _memberAccess.memberName() == "runtimeCode") { if (!m_constructorUsesAssembly) - m_constructorUsesAssembly = make_unique(); + m_constructorUsesAssembly = std::make_unique(); ContractType const& contract = dynamic_cast(*type->typeArgument()); if (m_constructorUsesAssembly->check(contract.contractDefinition())) m_errorReporter.warning( @@ -288,7 +287,7 @@ bool StaticAnalyzer::visit(InlineAssembly const& _inlineAssembly) { solAssert(!var->name().empty(), ""); if (var->isLocalVariable()) - m_localVarUseCount[make_pair(var->id(), var)] += 1; + m_localVarUseCount[std::make_pair(var->id(), var)] += 1; } } diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp index 4f99f67ac623..2546cfdda6bc 100644 --- a/libsolidity/analysis/SyntaxChecker.cpp +++ b/libsolidity/analysis/SyntaxChecker.cpp @@ -32,7 +32,6 @@ #include -using namespace std; using namespace solidity; using namespace solidity::langutil; using namespace solidity::frontend; @@ -55,17 +54,17 @@ void SyntaxChecker::endVisit(SourceUnit const& _sourceUnit) { if (!m_versionPragmaFound) { - string errorString("Source file does not specify required compiler version!"); - SemVerVersion recommendedVersion{string(VersionString)}; + std::string errorString("Source file does not specify required compiler version!"); + SemVerVersion recommendedVersion{std::string(VersionString)}; if (!recommendedVersion.isPrerelease()) errorString += " Consider adding \"pragma solidity ^" + - to_string(recommendedVersion.major()) + - string(".") + - to_string(recommendedVersion.minor()) + - string(".") + - to_string(recommendedVersion.patch()) + - string(";\""); + std::to_string(recommendedVersion.major()) + + std::string(".") + + std::to_string(recommendedVersion.minor()) + + std::string(".") + + std::to_string(recommendedVersion.patch()) + + std::string(";\""); // when reporting the warning, print the source name only m_errorReporter.warning(3420_error, {-1, -1, _sourceUnit.location().sourceName}, errorString); @@ -84,7 +83,7 @@ bool SyntaxChecker::visit(PragmaDirective const& _pragma) else if (_pragma.literals()[0] == "experimental") { solAssert(m_sourceUnit, ""); - vector literals(_pragma.literals().begin() + 1, _pragma.literals().end()); + std::vector literals(_pragma.literals().begin() + 1, _pragma.literals().end()); if (literals.empty()) m_errorReporter.syntaxError( 9679_error, @@ -99,7 +98,7 @@ bool SyntaxChecker::visit(PragmaDirective const& _pragma) ); else { - string const literal = literals[0]; + std::string const literal = literals[0]; if (literal.empty()) m_errorReporter.syntaxError(3250_error, _pragma.location(), "Empty experimental feature name is invalid."); else if (!ExperimentalFeatureNames.count(literal)) @@ -135,7 +134,7 @@ bool SyntaxChecker::visit(PragmaDirective const& _pragma) solAssert(m_sourceUnit, ""); if ( _pragma.literals().size() != 2 || - !set{"v1", "v2"}.count(_pragma.literals()[1]) + !std::set{"v1", "v2"}.count(_pragma.literals()[1]) ) m_errorReporter.syntaxError( 2745_error, @@ -155,17 +154,17 @@ bool SyntaxChecker::visit(PragmaDirective const& _pragma) { try { - vector tokens(_pragma.tokens().begin() + 1, _pragma.tokens().end()); - vector literals(_pragma.literals().begin() + 1, _pragma.literals().end()); + std::vector tokens(_pragma.tokens().begin() + 1, _pragma.tokens().end()); + std::vector literals(_pragma.literals().begin() + 1, _pragma.literals().end()); SemVerMatchExpressionParser parser(tokens, literals); SemVerMatchExpression matchExpression = parser.parse(); - static SemVerVersion const currentVersion{string(VersionString)}; + static SemVerVersion const currentVersion{std::string(VersionString)}; if (!matchExpression.matches(currentVersion)) m_errorReporter.syntaxError( 3997_error, _pragma.location(), "Source file requires different compiler version (current compiler is " + - string(VersionString) + ") - note that nightly builds are considered to be " + std::string(VersionString) + ") - note that nightly builds are considered to be " "strictly less than the released version" ); m_versionPragmaFound = true; @@ -412,7 +411,7 @@ bool SyntaxChecker::visit(UsingForDirective const& _usingFor) if (!_usingFor.usesBraces()) solAssert( _usingFor.functionsAndOperators().size() == 1 && - !get<1>(_usingFor.functionsAndOperators().front()) + !std::get<1>(_usingFor.functionsAndOperators().front()) ); if (!m_currentContractKind && !_usingFor.typeName()) @@ -455,7 +454,7 @@ bool SyntaxChecker::visit(FunctionDefinition const& _function) if (!_function.isFree() && !_function.isConstructor() && _function.noVisibilitySpecified()) { - string suggestedVisibility = + std::string suggestedVisibility = _function.isFallback() || _function.isReceive() || m_currentContractKind == ContractKind::Interface diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index e7721fd9e5b3..5c28d3cd2a78 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -51,7 +51,6 @@ #include #include -using namespace std; using namespace solidity; using namespace solidity::util; using namespace solidity::langutil; @@ -205,7 +204,7 @@ void TypeChecker::checkDoubleStorageAssignment(Assignment const& _assignment) TypePointers TypeChecker::typeCheckABIDecodeAndRetrieveReturnType(FunctionCall const& _functionCall, bool _abiEncoderV2) { - vector> arguments = _functionCall.arguments(); + std::vector> arguments = _functionCall.arguments(); if (arguments.size() != 2) m_errorReporter.typeError( 5782_error, @@ -296,7 +295,7 @@ TypePointers TypeChecker::typeCheckABIDecodeAndRetrieveReturnType(FunctionCall c TypePointers TypeChecker::typeCheckMetaTypeFunctionAndRetrieveReturnType(FunctionCall const& _functionCall) { - vector> arguments = _functionCall.arguments(); + std::vector> arguments = _functionCall.arguments(); if (arguments.size() != 1) m_errorReporter.fatalTypeError( 8885_error, @@ -442,7 +441,7 @@ bool TypeChecker::visit(FunctionDefinition const& _function) m_errorReporter.typeError(5587_error, _function.location(), "\"internal\" and \"private\" functions cannot be payable."); } - vector internalParametersInConstructor; + std::vector internalParametersInConstructor; auto checkArgumentAndReturnParameter = [&](VariableDeclaration const& _var) { if (type(_var)->containsNestedMapping()) @@ -472,7 +471,7 @@ bool TypeChecker::visit(FunctionDefinition const& _function) if (!iType) { - string message = iType.message(); + std::string message = iType.message(); solAssert(!message.empty(), "Expected detailed error message!"); if (_function.isConstructor()) message += " You can make the contract abstract to avoid this problem."; @@ -483,7 +482,7 @@ bool TypeChecker::visit(FunctionDefinition const& _function) !typeSupportedByOldABIEncoder(*type(_var), _function.libraryFunction()) ) { - string message = + std::string message = "This type is only supported in ABI coder v2. " "Use \"pragma abicoder v2;\" to enable the feature."; if (_function.isConstructor()) @@ -509,10 +508,10 @@ bool TypeChecker::visit(FunctionDefinition const& _function) var->accept(*this); } - set modifiers; + std::set modifiers; for (ASTPointer const& modifier: _function.modifiers()) { - vector baseContracts; + std::vector baseContracts; if (auto contract = dynamic_cast(_function.scope())) { baseContracts = contract->annotation().linearizedBaseContracts; @@ -522,7 +521,7 @@ bool TypeChecker::visit(FunctionDefinition const& _function) visitManually( *modifier, - _function.isConstructor() ? baseContracts : vector() + _function.isConstructor() ? baseContracts : std::vector() ); Declaration const* decl = &dereference(modifier->name()); if (modifiers.count(decl)) @@ -642,7 +641,7 @@ bool TypeChecker::visit(VariableDeclaration const& _variable) FunctionType getter(_variable); if (!useABICoderV2()) { - vector unsupportedTypes; + std::vector unsupportedTypes; for (auto const& param: getter.parameterTypes() + getter.returnParameterTypes()) if (!typeSupportedByOldABIEncoder(*param, false /* isLibrary */)) unsupportedTypes.emplace_back(param->humanReadableName()); @@ -713,7 +712,7 @@ void TypeChecker::endVisit(StructDefinition const& _struct) void TypeChecker::visitManually( ModifierInvocation const& _modifier, - vector const& _bases + std::vector const& _bases ) { std::vector> const& arguments = @@ -724,8 +723,8 @@ void TypeChecker::visitManually( _modifier.name().accept(*this); auto const* declaration = &dereference(_modifier.name()); - vector> emptyParameterList; - vector> const* parameters = nullptr; + std::vector> emptyParameterList; + std::vector> const* parameters = nullptr; if (auto modifierDecl = dynamic_cast(declaration)) { parameters = &modifierDecl->parameters(); @@ -920,8 +919,8 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly) if (!identifierInfo.suffix.empty()) { - string const& suffix = identifierInfo.suffix; - solAssert((set{"offset", "slot", "length", "selector", "address"}).count(suffix), ""); + std::string const& suffix = identifierInfo.suffix; + solAssert((std::set{"offset", "slot", "length", "selector", "address"}).count(suffix), ""); if (!var->isConstant() && (var->isStateVariable() || var->type()->dataStoredIn(DataLocation::Storage))) { if (suffix != "slot" && suffix != "offset") @@ -1042,7 +1041,7 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly) return true; }; solAssert(!_inlineAssembly.annotation().analysisInfo, ""); - _inlineAssembly.annotation().analysisInfo = make_shared(); + _inlineAssembly.annotation().analysisInfo = std::make_shared(); yul::AsmAnalyzer analyzer( *_inlineAssembly.annotation().analysisInfo, m_errorReporter, @@ -1113,9 +1112,9 @@ void TypeChecker::endVisit(TryStatement const& _tryStatement) 2800_error, successClause.location(), "Function returns " + - to_string(functionType.returnParameterTypes().size()) + + std::to_string(functionType.returnParameterTypes().size()) + " values, but returns clause has " + - to_string(parameters.size()) + + std::to_string(parameters.size()) + " variables." ); for (auto&& [parameter, returnType]: ranges::views::zip(parameters, returnTypes)) @@ -1363,7 +1362,7 @@ bool TypeChecker::visit(VariableDeclarationStatement const& _statement) else valueTypes = TypePointers{type(*_statement.initialValue())}; - vector> const& variables = _statement.declarations(); + std::vector> const& variables = _statement.declarations(); if (variables.empty()) // We already have an error for this in the SyntaxChecker. solAssert(m_errorReporter.hasErrors(), ""); @@ -1378,7 +1377,7 @@ bool TypeChecker::visit(VariableDeclarationStatement const& _statement) ")." ); - for (size_t i = 0; i < min(variables.size(), valueTypes.size()); ++i) + for (size_t i = 0; i < std::min(variables.size(), valueTypes.size()); ++i) { if (!variables[i]) continue; @@ -1535,14 +1534,14 @@ void TypeChecker::checkExpressionAssignment(Type const& _type, Expression const& m_errorReporter.typeError(5547_error, _expression.location(), "Empty tuple on the left hand side."); auto const* tupleType = dynamic_cast(&_type); - auto const& types = tupleType && tupleExpression->components().size() != 1 ? tupleType->components() : vector { &_type }; + auto const& types = tupleType && tupleExpression->components().size() != 1 ? tupleType->components() : std::vector { &_type }; solAssert( tupleExpression->components().size() == types.size() || m_errorReporter.hasErrors(), "Array sizes don't match and no errors generated." ); - for (size_t i = 0; i < min(tupleExpression->components().size(), types.size()); i++) + for (size_t i = 0; i < std::min(tupleExpression->components().size(), types.size()); i++) if (types[i]) { solAssert(!!tupleExpression->components()[i], ""); @@ -1607,7 +1606,7 @@ bool TypeChecker::visit(Assignment const& _assignment) 7366_error, _assignment.location(), "Operator " + - string(TokenTraits::friendlyName(_assignment.assignmentOperator())) + + std::string(TokenTraits::friendlyName(_assignment.assignmentOperator())) + " not compatible with types " + t->humanReadableName() + " and " + @@ -1621,7 +1620,7 @@ bool TypeChecker::visit(Assignment const& _assignment) bool TypeChecker::visit(TupleExpression const& _tuple) { _tuple.annotation().isConstant = false; - vector> const& components = _tuple.components(); + std::vector> const& components = _tuple.components(); TypePointers types; if (_tuple.annotation().willBeWrittenTo) @@ -1734,7 +1733,7 @@ bool TypeChecker::visit(UnaryOperation const& _operation) // Check if the operator is built-in or user-defined. TypeResult builtinResult = operandType->unaryOperatorResult(op); - set matchingDefinitions = operandType->operatorDefinitions( + std::set matchingDefinitions = operandType->operatorDefinitions( op, *currentDefinitionScope(), true // _unary @@ -1760,7 +1759,7 @@ bool TypeChecker::visit(UnaryOperation const& _operation) } else { - string description = fmt::format( + std::string description = fmt::format( "Built-in unary operator {} cannot be applied to type {}.", TokenTraits::friendlyName(op), operandType->humanReadableName() @@ -1802,7 +1801,7 @@ void TypeChecker::endVisit(BinaryOperation const& _operation) // Check if the operator is built-in or user-defined. TypeResult builtinResult = leftType->binaryOperatorResult(_operation.getOperator(), rightType); - set matchingDefinitions = leftType->operatorDefinitions( + std::set matchingDefinitions = leftType->operatorDefinitions( _operation.getOperator(), *currentDefinitionScope(), false // _unary @@ -1828,7 +1827,7 @@ void TypeChecker::endVisit(BinaryOperation const& _operation) } else { - string description = fmt::format( + std::string description = fmt::format( "Built-in binary operator {} cannot be applied to types {} and {}.", TokenTraits::friendlyName(_operation.getOperator()), leftType->humanReadableName(), @@ -1893,7 +1892,7 @@ void TypeChecker::endVisit(BinaryOperation const& _operation) if (_operation.getOperator() == Token::Exp || _operation.getOperator() == Token::SHL) { - string operation = _operation.getOperator() == Token::Exp ? "exponentiation" : "shift"; + std::string operation = _operation.getOperator() == Token::Exp ? "exponentiation" : "shift"; if ( leftType->category() == Type::Category::RationalNumber && rightType->category() != Type::Category::RationalNumber @@ -1933,7 +1932,7 @@ Type const* TypeChecker::typeCheckTypeConversionAndRetrieveReturnType( solAssert(*_functionCall.annotation().kind == FunctionCallKind::TypeConversion, ""); Type const* expressionType = type(_functionCall.expression()); - vector> const& arguments = _functionCall.arguments(); + std::vector> const& arguments = _functionCall.arguments(); bool const isPositionalCall = _functionCall.names().empty(); Type const* resultType = dynamic_cast(*expressionType).actualType(); @@ -2215,7 +2214,7 @@ void TypeChecker::typeCheckABIEncodeFunctions( } // Check additional arguments for variadic functions - vector> const& arguments = _functionCall.arguments(); + std::vector> const& arguments = _functionCall.arguments(); for (size_t i = 0; i < arguments.size(); ++i) { auto const& argType = type(*arguments[i]); @@ -2274,7 +2273,7 @@ void TypeChecker::typeCheckABIEncodeFunctions( void TypeChecker::typeCheckABIEncodeCallFunction(FunctionCall const& _functionCall) { - vector> const& arguments = _functionCall.arguments(); + std::vector> const& arguments = _functionCall.arguments(); // Expecting first argument to be the function pointer and second to be a tuple. if (arguments.size() != 2) @@ -2311,7 +2310,7 @@ void TypeChecker::typeCheckABIEncodeCallFunction(FunctionCall const& _functionCa externalFunctionType->kind() != FunctionType::Kind::Declaration ) { - string msg = "Expected regular external function type, or external view on public function."; + std::string msg = "Expected regular external function type, or external view on public function."; switch (externalFunctionType->kind()) { @@ -2360,7 +2359,7 @@ void TypeChecker::typeCheckABIEncodeCallFunction(FunctionCall const& _functionCa } solAssert(!externalFunctionType->takesArbitraryParameters(), "Function must have fixed parameters."); // Tuples with only one component become that component - vector> callArguments; + std::vector> callArguments; auto const* tupleType = dynamic_cast(type(*arguments[1])); if (tupleType) @@ -2387,9 +2386,9 @@ void TypeChecker::typeCheckABIEncodeCallFunction(FunctionCall const& _functionCa 7788_error, _functionCall.location(), "Expected " + - to_string(externalFunctionType->parameterTypes().size()) + + std::to_string(externalFunctionType->parameterTypes().size()) + " instead of " + - to_string(callArguments.size()) + + std::to_string(callArguments.size()) + " components for the tuple parameter." ); else @@ -2397,13 +2396,13 @@ void TypeChecker::typeCheckABIEncodeCallFunction(FunctionCall const& _functionCa 7515_error, _functionCall.location(), "Expected a tuple with " + - to_string(externalFunctionType->parameterTypes().size()) + + std::to_string(externalFunctionType->parameterTypes().size()) + " components instead of a single non-tuple parameter." ); } // Use min() to check as much as we can before failing fatally - size_t const numParameters = min(callArguments.size(), externalFunctionType->parameterTypes().size()); + size_t const numParameters = std::min(callArguments.size(), externalFunctionType->parameterTypes().size()); for (size_t i = 0; i < numParameters; i++) { @@ -2414,7 +2413,7 @@ void TypeChecker::typeCheckABIEncodeCallFunction(FunctionCall const& _functionCa 5407_error, callArguments[i]->location(), "Cannot implicitly convert component at position " + - to_string(i) + + std::to_string(i) + " from \"" + argType.humanReadableName() + "\" to \"" + @@ -2437,7 +2436,7 @@ void TypeChecker::typeCheckStringConcatFunction( typeCheckFunctionGeneralChecks(_functionCall, _functionType); - for (shared_ptr const& argument: _functionCall.arguments()) + for (std::shared_ptr const& argument: _functionCall.arguments()) { Type const* argumentType = type(*argument); bool notConvertibleToString = !argumentType->isImplicitlyConvertibleTo(*TypeProvider::stringMemory()); @@ -2464,7 +2463,7 @@ void TypeChecker::typeCheckBytesConcatFunction( typeCheckFunctionGeneralChecks(_functionCall, _functionType); - for (shared_ptr const& argument: _functionCall.arguments()) + for (std::shared_ptr const& argument: _functionCall.arguments()) { Type const* argumentType = type(*argument); bool notConvertibleToBytes = @@ -2504,8 +2503,8 @@ void TypeChecker::typeCheckFunctionGeneralChecks( ); TypePointers const& parameterTypes = _functionType->parameterTypes(); - vector> const& arguments = _functionCall.arguments(); - vector> const& argumentNames = _functionCall.names(); + std::vector> const& arguments = _functionCall.arguments(); + std::vector> const& argumentNames = _functionCall.names(); // Check number of passed in arguments if ( @@ -2516,22 +2515,22 @@ void TypeChecker::typeCheckFunctionGeneralChecks( bool const isStructConstructorCall = functionCallKind == FunctionCallKind::StructConstructorCall; - auto [errorId, description] = [&]() -> tuple { - string msg = isVariadic ? + auto [errorId, description] = [&]() -> std::tuple { + std::string msg = isVariadic ? "Need at least " + toString(parameterTypes.size()) + " arguments for " + - string(isStructConstructorCall ? "struct constructor" : "function call") + + std::string(isStructConstructorCall ? "struct constructor" : "function call") + ", but provided only " + toString(arguments.size()) + "." : "Wrong argument count for " + - string(isStructConstructorCall ? "struct constructor" : "function call") + + std::string(isStructConstructorCall ? "struct constructor" : "function call") + ": " + toString(arguments.size()) + " arguments given but " + - string(isVariadic ? "need at least " : "expected ") + + std::string(isVariadic ? "need at least " : "expected ") + toString(parameterTypes.size()) + "."; @@ -2659,8 +2658,8 @@ void TypeChecker::typeCheckFunctionGeneralChecks( BoolResult result = type(*paramArgMap[i])->isImplicitlyConvertibleTo(*parameterTypes[i]); if (!result) { - auto [errorId, description] = [&]() -> tuple { - string msg = + auto [errorId, description] = [&]() -> std::tuple { + std::string msg = "Invalid type for argument in function call. " "Invalid implicit conversion from " + type(*paramArgMap[i])->humanReadableName() + @@ -2751,7 +2750,7 @@ void TypeChecker::typeCheckFunctionGeneralChecks( bool TypeChecker::visit(FunctionCall const& _functionCall) { - vector> const& arguments = _functionCall.arguments(); + std::vector> const& arguments = _functionCall.arguments(); bool argumentsArePure = true; // We need to check arguments' type first as they will be needed for overload resolution. @@ -2991,7 +2990,7 @@ bool TypeChecker::visit(FunctionCallOptions const& _functionCallOptions) "{...}-option." ); - auto setCheckOption = [&](bool& _option, string const& _name) + auto setCheckOption = [&](bool& _option, std::string const& _name) { if (_option) m_errorReporter.typeError( @@ -3005,7 +3004,7 @@ bool TypeChecker::visit(FunctionCallOptions const& _functionCallOptions) for (size_t i = 0; i < _functionCallOptions.names().size(); ++i) { - string const& name = *(_functionCallOptions.names()[i]); + std::string const& name = *(_functionCallOptions.names()[i]); if (name == "salt") { if (kind == FunctionType::Kind::Creation) @@ -3185,8 +3184,8 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess) ); } - auto [errorId, description] = [&]() -> tuple { - string errorMsg = "Member \"" + memberName + "\" not found or not visible " + auto [errorId, description] = [&]() -> std::tuple { + std::string errorMsg = "Member \"" + memberName + "\" not found or not visible " "after argument-dependent lookup in " + exprType->humanReadableName() + "."; if (auto const* funType = dynamic_cast(exprType)) @@ -3222,7 +3221,7 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess) if (addressMember.name == memberName) { auto const* var = dynamic_cast(&_memberAccess.expression()); - string varName = var ? var->name() : "..."; + std::string varName = var ? var->name() : "..."; errorMsg += " Use \"address(" + varName + ")." + memberName + "\" to access this address member."; return { 3125_error, errorMsg }; } @@ -3606,13 +3605,13 @@ bool TypeChecker::visit(IndexRangeAccess const& _access) return false; } -vector TypeChecker::cleanOverloadedDeclarations( +std::vector TypeChecker::cleanOverloadedDeclarations( Identifier const& _identifier, - vector const& _candidates + std::vector const& _candidates ) { solAssert(_candidates.size() > 1, ""); - vector uniqueDeclarations; + std::vector uniqueDeclarations; for (Declaration const* declaration: _candidates) { @@ -3665,7 +3664,7 @@ bool TypeChecker::visit(Identifier const& _identifier) else if (!annotation.arguments) { // The identifier should be a public state variable shadowing other functions - vector candidates; + std::vector candidates; for (Declaration const* declaration: annotation.overloadedDeclarations) { @@ -3681,7 +3680,7 @@ bool TypeChecker::visit(Identifier const& _identifier) } else { - vector candidates; + std::vector candidates; for (Declaration const* declaration: annotation.overloadedDeclarations) { @@ -3700,7 +3699,7 @@ bool TypeChecker::visit(Identifier const& _identifier) if (!declaration->location().isValid()) { // Try to re-construct function definition - string description; + std::string description; for (auto const& param: declaration->functionType(true)->parameterTypes()) description += (description.empty() ? "" : ", ") + param->humanReadableName(); description = "function " + _identifier.name() + "(" + description + ")"; @@ -3816,12 +3815,12 @@ void TypeChecker::endVisit(Literal const& _literal) // Assign type here if it even looks like an address. This prevents double errors for invalid addresses _literal.annotation().type = TypeProvider::address(); - string msg; + std::string msg; if (_literal.valueWithoutUnderscores().length() != 42) // "0x" + 40 hex digits // looksLikeAddress enforces that it is a hex literal starting with "0x" msg = "This looks like an address but is not exactly 40 hex digits. It is " + - to_string(_literal.valueWithoutUnderscores().length() - 2) + + std::to_string(_literal.valueWithoutUnderscores().length() - 2) + " hex digits."; else if (!_literal.passesAddressChecksum()) { @@ -4034,7 +4033,7 @@ void TypeChecker::endVisit(UsingForDirective const& _usingFor) bool isBinaryOnlyOperator = (TokenTraits::isBinaryOp(operator_.value()) && !TokenTraits::isUnaryOp(operator_.value())); bool firstParameterMatchesUsingFor = parameterCount == 0 || *usingForType == *parameterTypes.front(); - optional wrongParametersMessage; + std::optional wrongParametersMessage; if (isBinaryOnlyOperator && (parameterCount != 2 || !identicalFirstTwoParameters)) wrongParametersMessage = fmt::format("two parameters of type {} and the same data location", usingForType->canonicalName()); else if (isUnaryOnlyOperator && (parameterCount != 1 || !firstParameterMatchesUsingFor)) @@ -4065,7 +4064,7 @@ void TypeChecker::endVisit(UsingForDirective const& _usingFor) TypePointers const& returnParameterTypes = functionType->returnParameterTypes(); size_t const returnParameterCount = returnParameterTypes.size(); - optional wrongReturnParametersMessage; + std::optional wrongReturnParametersMessage; if (!TokenTraits::isCompareOp(operator_.value()) && operator_.value() != Token::Not) { if (returnParameterCount != 1 || *usingForType != *returnParameterTypes.front()) @@ -4100,7 +4099,7 @@ void TypeChecker::endVisit(UsingForDirective const& _usingFor) { // TODO: This is pretty inefficient. For every operator binding we find, we're // traversing all bindings in all `using for` directives in the current scope. - set matchingDefinitions = usingForType->operatorDefinitions( + std::set matchingDefinitions = usingForType->operatorDefinitions( operator_.value(), *currentDefinitionScope(), parameterCount == 1 // _unary @@ -4133,7 +4132,7 @@ void TypeChecker::endVisit(UsingForDirective const& _usingFor) void TypeChecker::checkErrorAndEventParameters(CallableDeclaration const& _callable) { - string kind = dynamic_cast(&_callable) ? "event" : "error"; + std::string kind = dynamic_cast(&_callable) ? "event" : "error"; for (ASTPointer const& var: _callable.parameters()) { if (type(*var)->containsNestedMapping()) @@ -4223,7 +4222,7 @@ void TypeChecker::requireLValue(Expression const& _expression, bool _ordinaryAss if (*_expression.annotation().isLValue) return; - auto [errorId, description] = [&]() -> tuple { + auto [errorId, description] = [&]() -> std::tuple { if (*_expression.annotation().isConstant) return { 6520_error, "Cannot assign to a constant variable." }; diff --git a/libsolidity/analysis/ViewPureChecker.cpp b/libsolidity/analysis/ViewPureChecker.cpp index c370f8f9f149..3f6b954e75da 100644 --- a/libsolidity/analysis/ViewPureChecker.cpp +++ b/libsolidity/analysis/ViewPureChecker.cpp @@ -27,7 +27,6 @@ #include #include -using namespace std; using namespace solidity; using namespace solidity::langutil; using namespace solidity::frontend; @@ -312,13 +311,13 @@ ViewPureChecker::MutabilityAndLocation const& ViewPureChecker::modifierMutabilit { MutabilityAndLocation bestMutabilityAndLocation{}; FunctionDefinition const* currentFunction = nullptr; - swap(bestMutabilityAndLocation, m_bestMutabilityAndLocation); - swap(currentFunction, m_currentFunction); + std::swap(bestMutabilityAndLocation, m_bestMutabilityAndLocation); + std::swap(currentFunction, m_currentFunction); _modifier.accept(*this); - swap(bestMutabilityAndLocation, m_bestMutabilityAndLocation); - swap(currentFunction, m_currentFunction); + std::swap(bestMutabilityAndLocation, m_bestMutabilityAndLocation); + std::swap(currentFunction, m_currentFunction); } return m_inferredMutability.at(&_modifier); } @@ -384,8 +383,8 @@ void ViewPureChecker::endVisit(MemberAccess const& _memberAccess) break; case Type::Category::Magic: { - using MagicMember = pair; - set static const pureMembers{ + using MagicMember = std::pair; + std::set static const pureMembers{ {MagicType::Kind::ABI, "decode"}, {MagicType::Kind::ABI, "encode"}, {MagicType::Kind::ABI, "encodePacked"}, @@ -401,7 +400,7 @@ void ViewPureChecker::endVisit(MemberAccess const& _memberAccess) {MagicType::Kind::MetaType, "min"}, {MagicType::Kind::MetaType, "max"}, }; - set static const payableMembers{ + std::set static const payableMembers{ {MagicType::Kind::Message, "value"} }; diff --git a/scripts/check_style.sh b/scripts/check_style.sh index 34fbf0381bf7..a396a7d76059 100755 --- a/scripts/check_style.sh +++ b/scripts/check_style.sh @@ -25,6 +25,7 @@ NAMESPACE_STD_FREE_FILES=( liblangutil/* libsmtutil/* libsolc/* + libsolidity/analysis/* ) (