Apply modernize-pass-by-value.

This commit is contained in:
Alexander Arlt 2020-03-31 22:04:29 -05:00
parent 79a44b8170
commit aac7a1e434
29 changed files with 243 additions and 212 deletions

View File

@ -22,15 +22,17 @@
*/
#include <libevmasm/ExpressionClasses.h>
#include <utility>
#include <tuple>
#include <functional>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/noncopyable.hpp>
#include <libevmasm/Assembly.h>
#include <libevmasm/CommonSubexpressionEliminator.h>
#include <libevmasm/SimplificationRules.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/noncopyable.hpp>
#include <functional>
#include <tuple>
#include <utility>
using namespace std;
using namespace solidity;
using namespace solidity::evmasm;

View File

@ -28,6 +28,7 @@
#include <ostream>
#include <tuple>
#include <utility>
namespace solidity::evmasm
{
@ -119,7 +120,7 @@ public:
struct GasConsumption
{
GasConsumption(unsigned _value = 0, bool _infinite = false): value(_value), isInfinite(_infinite) {}
GasConsumption(u256 _value, bool _infinite = false): value(_value), isInfinite(_infinite) {}
GasConsumption(u256 _value, bool _infinite = false): value(std::move(_value)), isInfinite(_infinite) {}
static GasConsumption infinite() { return GasConsumption(0, true); }
GasConsumption& operator+=(GasConsumption const& _other);
@ -133,8 +134,8 @@ public:
};
/// Constructs a new gas meter given the current state.
GasMeter(std::shared_ptr<KnownState> const& _state, langutil::EVMVersion _evmVersion, u256 const& _largestMemoryAccess = 0):
m_state(_state), m_evmVersion(_evmVersion), m_largestMemoryAccess(_largestMemoryAccess) {}
GasMeter(std::shared_ptr<KnownState> _state, langutil::EVMVersion _evmVersion, u256 _largestMemoryAccess = 0):
m_state(std::move(_state)), m_evmVersion(_evmVersion), m_largestMemoryAccess(std::move(_largestMemoryAccess)) {}
/// @returns an upper bound on the gas consumed by the given instruction and updates
/// the state.

View File

@ -23,6 +23,7 @@
#pragma once
#include <utility>
#include <vector>
#include <map>
#include <set>
@ -83,7 +84,7 @@ public:
explicit KnownState(
std::shared_ptr<ExpressionClasses> _expressionClasses = std::make_shared<ExpressionClasses>()
): m_expressionClasses(_expressionClasses)
): m_expressionClasses(std::move(_expressionClasses))
{
}

View File

@ -55,6 +55,7 @@
#include <cstdint>
#include <string>
#include <tuple>
#include <utility>
namespace solidity::langutil
{
@ -68,8 +69,8 @@ class CharStream
{
public:
CharStream() = default;
explicit CharStream(std::string const& _source, std::string const& name):
m_source(_source), m_name(name) {}
explicit CharStream(std::string _source, std::string name):
m_source(std::move(_source)), m_name(std::move(name)) {}
int position() const { return m_position; }
bool isPastEndOfInput(size_t _charsForward = 0) const { return (m_position + _charsForward) >= m_source.size(); }

View File

@ -22,15 +22,16 @@
#pragma once
#include <string>
#include <utility>
#include <vector>
#include <memory>
#include <libsolutil/Exceptions.h>
#include <libsolutil/Assertions.h>
#include <libsolutil/CommonData.h>
#include <liblangutil/SourceLocation.h>
#include <string>
#include <utility>
#include <vector>
#include <memory>
namespace solidity::langutil
{
class Error;

View File

@ -23,7 +23,9 @@
#pragma once
#include <liblangutil/Token.h>
#include <string>
#include <utility>
#include <vector>
namespace solidity::langutil
@ -80,8 +82,8 @@ struct SemVerMatchExpression
class SemVerMatchExpressionParser
{
public:
SemVerMatchExpressionParser(std::vector<Token> const& _tokens, std::vector<std::string> const& _literals):
m_tokens(_tokens), m_literals(_literals)
SemVerMatchExpressionParser(std::vector<Token> _tokens, std::vector<std::string> _literals):
m_tokens(std::move(_tokens)), m_literals(std::move(_literals))
{}
SemVerMatchExpression parse();

View File

@ -24,6 +24,8 @@
#include <libsolidity/ast/ASTVisitor.h>
#include <utility>
namespace solidity::langutil
{
class ErrorReporter;
@ -47,7 +49,7 @@ public:
):
m_errorReporter(_errorReporter),
m_depth(_newDepth),
m_types(_types)
m_types(std::move(_types))
{
}

View File

@ -26,6 +26,7 @@
#include <map>
#include <memory>
#include <stack>
#include <utility>
#include <vector>
namespace solidity::frontend
@ -48,8 +49,8 @@ public:
Assignment,
InlineAssembly
};
VariableOccurrence(VariableDeclaration const& _declaration, Kind _kind, std::optional<langutil::SourceLocation> const& _occurrence = {}):
m_declaration(_declaration), m_occurrenceKind(_kind), m_occurrence(_occurrence)
VariableOccurrence(VariableDeclaration const& _declaration, Kind _kind, std::optional<langutil::SourceLocation> _occurrence = {}):
m_declaration(_declaration), m_occurrenceKind(_kind), m_occurrence(std::move(_occurrence))
{
}

View File

@ -23,6 +23,7 @@
#include <libevmasm/SemanticInformation.h>
#include <functional>
#include <utility>
#include <variant>
using namespace std;
@ -41,7 +42,7 @@ public:
std::function<void(StateMutability, SourceLocation const&)> _reportMutability
):
m_dialect(_dialect),
m_reportMutability(_reportMutability) {}
m_reportMutability(std::move(_reportMutability)) {}
void operator()(yul::Literal const&) {}
void operator()(yul::Identifier const&) {}

View File

@ -28,16 +28,18 @@
#include <libsolutil/Keccak256.h>
#include <boost/algorithm/string.hpp>
#include <algorithm>
#include <functional>
#include <utility>
using namespace std;
using namespace solidity;
using namespace solidity::frontend;
ASTNode::ASTNode(int64_t _id, SourceLocation const& _location):
ASTNode::ASTNode(int64_t _id, SourceLocation _location):
m_id(_id),
m_location(_location)
m_location(std::move(_location))
{
}

View File

@ -38,6 +38,7 @@
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>
namespace solidity::yul
@ -82,7 +83,7 @@ public:
using SourceLocation = langutil::SourceLocation;
explicit ASTNode(int64_t _id, SourceLocation const& _location);
explicit ASTNode(int64_t _id, SourceLocation _location);
virtual ~ASTNode() {}
/// @returns an identifier of this AST node that is unique for a single compilation run.
@ -155,8 +156,8 @@ std::vector<T const*> ASTNode::filteredNodes(std::vector<ASTPointer<ASTNode>> co
class SourceUnit: public ASTNode
{
public:
SourceUnit(int64_t _id, SourceLocation const& _location, std::vector<ASTPointer<ASTNode>> const& _nodes):
ASTNode(_id, _location), m_nodes(_nodes) {}
SourceUnit(int64_t _id, SourceLocation const& _location, std::vector<ASTPointer<ASTNode>> _nodes):
ASTNode(_id, _location), m_nodes(std::move(_nodes)) {}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
@ -224,10 +225,10 @@ public:
Declaration(
int64_t _id,
SourceLocation const& _location,
ASTPointer<ASTString> const& _name,
ASTPointer<ASTString> _name,
Visibility _visibility = Visibility::Default
):
ASTNode(_id, _location), m_name(_name), m_visibility(_visibility) {}
ASTNode(_id, _location), m_name(std::move(_name)), m_visibility(_visibility) {}
/// @returns the declared name.
ASTString const& name() const { return *m_name; }
@ -275,9 +276,9 @@ public:
PragmaDirective(
int64_t _id,
SourceLocation const& _location,
std::vector<Token> const& _tokens,
std::vector<ASTString> const& _literals
): ASTNode(_id, _location), m_tokens(_tokens), m_literals(_literals)
std::vector<Token> _tokens,
std::vector<ASTString> _literals
): ASTNode(_id, _location), m_tokens(std::move(_tokens)), m_literals(std::move(_literals))
{}
void accept(ASTVisitor& _visitor) override;
@ -318,12 +319,12 @@ public:
ImportDirective(
int64_t _id,
SourceLocation const& _location,
ASTPointer<ASTString> const& _path,
ASTPointer<ASTString> _path,
ASTPointer<ASTString> const& _unitAlias,
SymbolAliasList _symbolAliases
):
Declaration(_id, _location, _unitAlias),
m_path(_path),
m_path(std::move(_path)),
m_symbolAliases(move(_symbolAliases))
{ }
@ -372,8 +373,8 @@ public:
StructuredDocumentation(
int64_t _id,
SourceLocation const& _location,
ASTPointer<ASTString> const& _text
): ASTNode(_id, _location), m_text(_text)
ASTPointer<ASTString> _text
): ASTNode(_id, _location), m_text(std::move(_text))
{}
void accept(ASTVisitor& _visitor) override;
@ -394,7 +395,7 @@ class Documented
{
public:
virtual ~Documented() = default;
explicit Documented(ASTPointer<ASTString> const& _documentation): m_documentation(_documentation) {}
explicit Documented(ASTPointer<ASTString> _documentation): m_documentation(std::move(_documentation)) {}
/// @return A shared pointer of an ASTString.
/// Can contain a nullptr in which case indicates absence of documentation
@ -411,7 +412,7 @@ class StructurallyDocumented
{
public:
virtual ~StructurallyDocumented() = default;
explicit StructurallyDocumented(ASTPointer<StructuredDocumentation> const& _documentation): m_documentation(_documentation) {}
explicit StructurallyDocumented(ASTPointer<StructuredDocumentation> _documentation): m_documentation(std::move(_documentation)) {}
/// @return A shared pointer of a FormalDocumentation.
/// Can contain a nullptr in which case indicates absence of documentation
@ -453,15 +454,15 @@ public:
SourceLocation const& _location,
ASTPointer<ASTString> const& _name,
ASTPointer<StructuredDocumentation> const& _documentation,
std::vector<ASTPointer<InheritanceSpecifier>> const& _baseContracts,
std::vector<ASTPointer<ASTNode>> const& _subNodes,
std::vector<ASTPointer<InheritanceSpecifier>> _baseContracts,
std::vector<ASTPointer<ASTNode>> _subNodes,
ContractKind _contractKind = ContractKind::Contract,
bool _abstract = false
):
Declaration(_id, _location, _name),
StructurallyDocumented(_documentation),
m_baseContracts(_baseContracts),
m_subNodes(_subNodes),
m_baseContracts(std::move(_baseContracts)),
m_subNodes(std::move(_subNodes)),
m_contractKind(_contractKind),
m_abstract(_abstract)
{}
@ -538,10 +539,10 @@ public:
InheritanceSpecifier(
int64_t _id,
SourceLocation const& _location,
ASTPointer<UserDefinedTypeName> const& _baseName,
ASTPointer<UserDefinedTypeName> _baseName,
std::unique_ptr<std::vector<ASTPointer<Expression>>> _arguments
):
ASTNode(_id, _location), m_baseName(_baseName), m_arguments(std::move(_arguments)) {}
ASTNode(_id, _location), m_baseName(std::move(_baseName)), m_arguments(std::move(_arguments)) {}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
@ -568,10 +569,10 @@ public:
UsingForDirective(
int64_t _id,
SourceLocation const& _location,
ASTPointer<UserDefinedTypeName> const& _libraryName,
ASTPointer<TypeName> const& _typeName
ASTPointer<UserDefinedTypeName> _libraryName,
ASTPointer<TypeName> _typeName
):
ASTNode(_id, _location), m_libraryName(_libraryName), m_typeName(_typeName) {}
ASTNode(_id, _location), m_libraryName(std::move(_libraryName)), m_typeName(std::move(_typeName)) {}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
@ -592,9 +593,9 @@ public:
int64_t _id,
SourceLocation const& _location,
ASTPointer<ASTString> const& _name,
std::vector<ASTPointer<VariableDeclaration>> const& _members
std::vector<ASTPointer<VariableDeclaration>> _members
):
Declaration(_id, _location, _name), m_members(_members) {}
Declaration(_id, _location, _name), m_members(std::move(_members)) {}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
@ -619,9 +620,9 @@ public:
int64_t _id,
SourceLocation const& _location,
ASTPointer<ASTString> const& _name,
std::vector<ASTPointer<EnumValue>> const& _members
std::vector<ASTPointer<EnumValue>> _members
):
Declaration(_id, _location, _name), m_members(_members) {}
Declaration(_id, _location, _name), m_members(std::move(_members)) {}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
@ -664,9 +665,9 @@ public:
ParameterList(
int64_t _id,
SourceLocation const& _location,
std::vector<ASTPointer<VariableDeclaration>> const& _parameters
std::vector<ASTPointer<VariableDeclaration>> _parameters
):
ASTNode(_id, _location), m_parameters(_parameters) {}
ASTNode(_id, _location), m_parameters(std::move(_parameters)) {}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
@ -688,15 +689,15 @@ public:
SourceLocation const& _location,
ASTPointer<ASTString> const& _name,
Visibility _visibility,
ASTPointer<ParameterList> const& _parameters,
ASTPointer<ParameterList> _parameters,
bool _isVirtual = false,
ASTPointer<OverrideSpecifier> const& _overrides = nullptr,
ASTPointer<ParameterList> const& _returnParameters = ASTPointer<ParameterList>()
ASTPointer<OverrideSpecifier> _overrides = nullptr,
ASTPointer<ParameterList> _returnParameters = ASTPointer<ParameterList>()
):
Declaration(_id, _location, _name, _visibility),
m_parameters(_parameters),
m_overrides(_overrides),
m_returnParameters(_returnParameters),
m_parameters(std::move(_parameters)),
m_overrides(std::move(_overrides)),
m_returnParameters(std::move(_returnParameters)),
m_isVirtual(_isVirtual)
{
}
@ -740,10 +741,10 @@ public:
OverrideSpecifier(
int64_t _id,
SourceLocation const& _location,
std::vector<ASTPointer<UserDefinedTypeName>> const& _overrides
std::vector<ASTPointer<UserDefinedTypeName>> _overrides
):
ASTNode(_id, _location),
m_overrides(_overrides)
m_overrides(std::move(_overrides))
{
}
@ -771,7 +772,7 @@ public:
ASTPointer<OverrideSpecifier> const& _overrides,
ASTPointer<StructuredDocumentation> const& _documentation,
ASTPointer<ParameterList> const& _parameters,
std::vector<ASTPointer<ModifierInvocation>> const& _modifiers,
std::vector<ASTPointer<ModifierInvocation>> _modifiers,
ASTPointer<ParameterList> const& _returnParameters,
ASTPointer<Block> const& _body
):
@ -780,7 +781,7 @@ public:
ImplementationOptional(_body != nullptr),
m_stateMutability(_stateMutability),
m_kind(_kind),
m_functionModifiers(_modifiers),
m_functionModifiers(std::move(_modifiers)),
m_body(_body)
{
solAssert(_kind == Token::Constructor || _kind == Token::Function || _kind == Token::Fallback || _kind == Token::Receive, "");
@ -869,23 +870,23 @@ public:
VariableDeclaration(
int64_t _id,
SourceLocation const& _location,
ASTPointer<TypeName> const& _type,
ASTPointer<TypeName> _type,
ASTPointer<ASTString> const& _name,
ASTPointer<Expression> _value,
Visibility _visibility,
bool _isStateVar = false,
bool _isIndexed = false,
Mutability _mutability = Mutability::Mutable,
ASTPointer<OverrideSpecifier> const& _overrides = nullptr,
ASTPointer<OverrideSpecifier> _overrides = nullptr,
Location _referenceLocation = Location::Unspecified
):
Declaration(_id, _location, _name, _visibility),
m_typeName(_type),
m_value(_value),
m_typeName(std::move(_type)),
m_value(std::move(_value)),
m_isStateVariable(_isStateVar),
m_isIndexed(_isIndexed),
m_mutability(_mutability),
m_overrides(_overrides),
m_overrides(std::move(_overrides)),
m_location(_referenceLocation) {}
@ -977,11 +978,11 @@ public:
ASTPointer<ParameterList> const& _parameters,
bool _isVirtual,
ASTPointer<OverrideSpecifier> const& _overrides,
ASTPointer<Block> const& _body
ASTPointer<Block> _body
):
CallableDeclaration(_id, _location, _name, Visibility::Internal, _parameters, _isVirtual, _overrides),
StructurallyDocumented(_documentation),
m_body(_body)
m_body(std::move(_body))
{
}
@ -1015,10 +1016,10 @@ public:
ModifierInvocation(
int64_t _id,
SourceLocation const& _location,
ASTPointer<Identifier> const& _name,
ASTPointer<Identifier> _name,
std::unique_ptr<std::vector<ASTPointer<Expression>>> _arguments
):
ASTNode(_id, _location), m_modifierName(_name), m_arguments(std::move(_arguments)) {}
ASTNode(_id, _location), m_modifierName(std::move(_name)), m_arguments(std::move(_arguments)) {}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
@ -1159,8 +1160,8 @@ private:
class UserDefinedTypeName: public TypeName
{
public:
UserDefinedTypeName(int64_t _id, SourceLocation const& _location, std::vector<ASTString> const& _namePath):
TypeName(_id, _location), m_namePath(_namePath) {}
UserDefinedTypeName(int64_t _id, SourceLocation const& _location, std::vector<ASTString> _namePath):
TypeName(_id, _location), m_namePath(std::move(_namePath)) {}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
@ -1181,12 +1182,12 @@ public:
FunctionTypeName(
int64_t _id,
SourceLocation const& _location,
ASTPointer<ParameterList> const& _parameterTypes,
ASTPointer<ParameterList> const& _returnTypes,
ASTPointer<ParameterList> _parameterTypes,
ASTPointer<ParameterList> _returnTypes,
Visibility _visibility,
StateMutability _stateMutability
):
TypeName(_id, _location), m_parameterTypes(_parameterTypes), m_returnTypes(_returnTypes),
TypeName(_id, _location), m_parameterTypes(std::move(_parameterTypes)), m_returnTypes(std::move(_returnTypes)),
m_visibility(_visibility), m_stateMutability(_stateMutability)
{}
void accept(ASTVisitor& _visitor) override;
@ -1220,10 +1221,10 @@ public:
Mapping(
int64_t _id,
SourceLocation const& _location,
ASTPointer<TypeName> const& _keyType,
ASTPointer<TypeName> const& _valueType
ASTPointer<TypeName> _keyType,
ASTPointer<TypeName> _valueType
):
TypeName(_id, _location), m_keyType(_keyType), m_valueType(_valueType) {}
TypeName(_id, _location), m_keyType(std::move(_keyType)), m_valueType(std::move(_valueType)) {}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
@ -1244,10 +1245,10 @@ public:
ArrayTypeName(
int64_t _id,
SourceLocation const& _location,
ASTPointer<TypeName> const& _baseType,
ASTPointer<Expression> const& _length
ASTPointer<TypeName> _baseType,
ASTPointer<Expression> _length
):
TypeName(_id, _location), m_baseType(_baseType), m_length(_length) {}
TypeName(_id, _location), m_baseType(std::move(_baseType)), m_length(std::move(_length)) {}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
@ -1291,9 +1292,9 @@ public:
SourceLocation const& _location,
ASTPointer<ASTString> const& _docString,
yul::Dialect const& _dialect,
std::shared_ptr<yul::Block> const& _operations
std::shared_ptr<yul::Block> _operations
):
Statement(_id, _location, _docString), m_dialect(_dialect), m_operations(_operations) {}
Statement(_id, _location, _docString), m_dialect(_dialect), m_operations(std::move(_operations)) {}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
@ -1317,9 +1318,9 @@ public:
int64_t _id,
SourceLocation const& _location,
ASTPointer<ASTString> const& _docString,
std::vector<ASTPointer<Statement>> const& _statements
std::vector<ASTPointer<Statement>> _statements
):
Statement(_id, _location, _docString), m_statements(_statements) {}
Statement(_id, _location, _docString), m_statements(std::move(_statements)) {}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
@ -1359,14 +1360,14 @@ public:
int64_t _id,
SourceLocation const& _location,
ASTPointer<ASTString> const& _docString,
ASTPointer<Expression> const& _condition,
ASTPointer<Statement> const& _trueBody,
ASTPointer<Statement> const& _falseBody
ASTPointer<Expression> _condition,
ASTPointer<Statement> _trueBody,
ASTPointer<Statement> _falseBody
):
Statement(_id, _location, _docString),
m_condition(_condition),
m_trueBody(_trueBody),
m_falseBody(_falseBody)
m_condition(std::move(_condition)),
m_trueBody(std::move(_trueBody)),
m_falseBody(std::move(_falseBody))
{}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
@ -1393,14 +1394,14 @@ public:
TryCatchClause(
int64_t _id,
SourceLocation const& _location,
ASTPointer<ASTString> const& _errorName,
ASTPointer<ParameterList> const& _parameters,
ASTPointer<Block> const& _block
ASTPointer<ASTString> _errorName,
ASTPointer<ParameterList> _parameters,
ASTPointer<Block> _block
):
ASTNode(_id, _location),
m_errorName(_errorName),
m_parameters(_parameters),
m_block(_block)
m_errorName(std::move(_errorName)),
m_parameters(std::move(_parameters)),
m_block(std::move(_block))
{}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
@ -1438,12 +1439,12 @@ public:
int64_t _id,
SourceLocation const& _location,
ASTPointer<ASTString> const& _docString,
ASTPointer<Expression> const& _externalCall,
std::vector<ASTPointer<TryCatchClause>> const& _clauses
ASTPointer<Expression> _externalCall,
std::vector<ASTPointer<TryCatchClause>> _clauses
):
Statement(_id, _location, _docString),
m_externalCall(_externalCall),
m_clauses(_clauses)
m_externalCall(std::move(_externalCall)),
m_clauses(std::move(_clauses))
{}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
@ -1476,11 +1477,11 @@ public:
int64_t _id,
SourceLocation const& _location,
ASTPointer<ASTString> const& _docString,
ASTPointer<Expression> const& _condition,
ASTPointer<Statement> const& _body,
ASTPointer<Expression> _condition,
ASTPointer<Statement> _body,
bool _isDoWhile
):
BreakableStatement(_id, _location, _docString), m_condition(_condition), m_body(_body),
BreakableStatement(_id, _location, _docString), m_condition(std::move(_condition)), m_body(std::move(_body)),
m_isDoWhile(_isDoWhile) {}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
@ -1505,16 +1506,16 @@ public:
int64_t _id,
SourceLocation const& _location,
ASTPointer<ASTString> const& _docString,
ASTPointer<Statement> const& _initExpression,
ASTPointer<Expression> const& _conditionExpression,
ASTPointer<ExpressionStatement> const& _loopExpression,
ASTPointer<Statement> const& _body
ASTPointer<Statement> _initExpression,
ASTPointer<Expression> _conditionExpression,
ASTPointer<ExpressionStatement> _loopExpression,
ASTPointer<Statement> _body
):
BreakableStatement(_id, _location, _docString),
m_initExpression(_initExpression),
m_condExpression(_conditionExpression),
m_loopExpression(_loopExpression),
m_body(_body)
m_initExpression(std::move(_initExpression)),
m_condExpression(std::move(_conditionExpression)),
m_loopExpression(std::move(_loopExpression)),
m_body(std::move(_body))
{}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
@ -1563,7 +1564,7 @@ public:
SourceLocation const& _location,
ASTPointer<ASTString> const& _docString,
ASTPointer<Expression> _expression
): Statement(_id, _location, _docString), m_expression(_expression) {}
): Statement(_id, _location, _docString), m_expression(std::move(_expression)) {}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
@ -1597,9 +1598,9 @@ public:
int64_t _id,
SourceLocation const& _location,
ASTPointer<ASTString> const& _docString,
ASTPointer<FunctionCall> const& _functionCall
ASTPointer<FunctionCall> _functionCall
):
Statement(_id, _location, _docString), m_eventCall(_functionCall) {}
Statement(_id, _location, _docString), m_eventCall(std::move(_functionCall)) {}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
@ -1624,10 +1625,10 @@ public:
int64_t _id,
SourceLocation const& _location,
ASTPointer<ASTString> const& _docString,
std::vector<ASTPointer<VariableDeclaration>> const& _variables,
ASTPointer<Expression> const& _initialValue
std::vector<ASTPointer<VariableDeclaration>> _variables,
ASTPointer<Expression> _initialValue
):
Statement(_id, _location, _docString), m_variables(_variables), m_initialValue(_initialValue) {}
Statement(_id, _location, _docString), m_variables(std::move(_variables)), m_initialValue(std::move(_initialValue)) {}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
@ -1656,7 +1657,7 @@ public:
ASTPointer<ASTString> const& _docString,
ASTPointer<Expression> _expression
):
Statement(_id, _location, _docString), m_expression(_expression) {}
Statement(_id, _location, _docString), m_expression(std::move(_expression)) {}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
@ -1690,14 +1691,14 @@ public:
Conditional(
int64_t _id,
SourceLocation const& _location,
ASTPointer<Expression> const& _condition,
ASTPointer<Expression> const& _trueExpression,
ASTPointer<Expression> const& _falseExpression
ASTPointer<Expression> _condition,
ASTPointer<Expression> _trueExpression,
ASTPointer<Expression> _falseExpression
):
Expression(_id, _location),
m_condition(_condition),
m_trueExpression(_trueExpression),
m_falseExpression(_falseExpression)
m_condition(std::move(_condition)),
m_trueExpression(std::move(_trueExpression)),
m_falseExpression(std::move(_falseExpression))
{}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
@ -1720,14 +1721,14 @@ public:
Assignment(
int64_t _id,
SourceLocation const& _location,
ASTPointer<Expression> const& _leftHandSide,
ASTPointer<Expression> _leftHandSide,
Token _assignmentOperator,
ASTPointer<Expression> const& _rightHandSide
ASTPointer<Expression> _rightHandSide
):
Expression(_id, _location),
m_leftHandSide(_leftHandSide),
m_leftHandSide(std::move(_leftHandSide)),
m_assigmentOperator(_assignmentOperator),
m_rightHandSide(_rightHandSide)
m_rightHandSide(std::move(_rightHandSide))
{
solAssert(TokenTraits::isAssignmentOp(_assignmentOperator), "");
}
@ -1758,11 +1759,11 @@ public:
TupleExpression(
int64_t _id,
SourceLocation const& _location,
std::vector<ASTPointer<Expression>> const& _components,
std::vector<ASTPointer<Expression>> _components,
bool _isArray
):
Expression(_id, _location),
m_components(_components),
m_components(std::move(_components)),
m_isArray(_isArray) {}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
@ -1786,12 +1787,12 @@ public:
int64_t _id,
SourceLocation const& _location,
Token _operator,
ASTPointer<Expression> const& _subExpression,
ASTPointer<Expression> _subExpression,
bool _isPrefix
):
Expression(_id, _location),
m_operator(_operator),
m_subExpression(_subExpression),
m_subExpression(std::move(_subExpression)),
m_isPrefix(_isPrefix)
{
solAssert(TokenTraits::isUnaryOp(_operator), "");
@ -1819,11 +1820,11 @@ public:
BinaryOperation(
int64_t _id,
SourceLocation const& _location,
ASTPointer<Expression> const& _left,
ASTPointer<Expression> _left,
Token _operator,
ASTPointer<Expression> const& _right
ASTPointer<Expression> _right
):
Expression(_id, _location), m_left(_left), m_operator(_operator), m_right(_right)
Expression(_id, _location), m_left(std::move(_left)), m_operator(_operator), m_right(std::move(_right))
{
solAssert(TokenTraits::isBinaryOp(_operator) || TokenTraits::isCompareOp(_operator), "");
}
@ -1851,11 +1852,11 @@ public:
FunctionCall(
int64_t _id,
SourceLocation const& _location,
ASTPointer<Expression> const& _expression,
std::vector<ASTPointer<Expression>> const& _arguments,
std::vector<ASTPointer<ASTString>> const& _names
ASTPointer<Expression> _expression,
std::vector<ASTPointer<Expression>> _arguments,
std::vector<ASTPointer<ASTString>> _names
):
Expression(_id, _location), m_expression(_expression), m_arguments(_arguments), m_names(_names) {}
Expression(_id, _location), m_expression(std::move(_expression)), m_arguments(std::move(_arguments)), m_names(std::move(_names)) {}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
@ -1881,11 +1882,11 @@ public:
FunctionCallOptions(
int64_t _id,
SourceLocation const& _location,
ASTPointer<Expression> const& _expression,
std::vector<ASTPointer<Expression>> const& _options,
std::vector<ASTPointer<ASTString>> const& _names
ASTPointer<Expression> _expression,
std::vector<ASTPointer<Expression>> _options,
std::vector<ASTPointer<ASTString>> _names
):
Expression(_id, _location), m_expression(_expression), m_options(_options), m_names(_names) {}
Expression(_id, _location), m_expression(std::move(_expression)), m_options(std::move(_options)), m_names(std::move(_names)) {}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
@ -1910,9 +1911,9 @@ public:
NewExpression(
int64_t _id,
SourceLocation const& _location,
ASTPointer<TypeName> const& _typeName
ASTPointer<TypeName> _typeName
):
Expression(_id, _location), m_typeName(_typeName) {}
Expression(_id, _location), m_typeName(std::move(_typeName)) {}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
@ -1932,9 +1933,9 @@ public:
int64_t _id,
SourceLocation const& _location,
ASTPointer<Expression> _expression,
ASTPointer<ASTString> const& _memberName
ASTPointer<ASTString> _memberName
):
Expression(_id, _location), m_expression(_expression), m_memberName(_memberName) {}
Expression(_id, _location), m_expression(std::move(_expression)), m_memberName(std::move(_memberName)) {}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
Expression const& expression() const { return *m_expression; }
@ -1956,10 +1957,10 @@ public:
IndexAccess(
int64_t _id,
SourceLocation const& _location,
ASTPointer<Expression> const& _base,
ASTPointer<Expression> const& _index
ASTPointer<Expression> _base,
ASTPointer<Expression> _index
):
Expression(_id, _location), m_base(_base), m_index(_index) {}
Expression(_id, _location), m_base(std::move(_base)), m_index(std::move(_index)) {}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
@ -1980,11 +1981,11 @@ public:
IndexRangeAccess(
int64_t _id,
SourceLocation const& _location,
ASTPointer<Expression> const& _base,
ASTPointer<Expression> const& _start,
ASTPointer<Expression> const& _end
ASTPointer<Expression> _base,
ASTPointer<Expression> _start,
ASTPointer<Expression> _end
):
Expression(_id, _location), m_base(_base), m_start(_start), m_end(_end) {}
Expression(_id, _location), m_base(std::move(_base)), m_start(std::move(_start)), m_end(std::move(_end)) {}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
@ -2017,9 +2018,9 @@ public:
Identifier(
int64_t _id,
SourceLocation const& _location,
ASTPointer<ASTString> const& _name
ASTPointer<ASTString> _name
):
PrimaryExpression(_id, _location), m_name(_name) {}
PrimaryExpression(_id, _location), m_name(std::move(_name)) {}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
@ -2042,10 +2043,10 @@ public:
ElementaryTypeNameExpression(
int64_t _id,
SourceLocation const& _location,
ASTPointer<ElementaryTypeName> const& _type
ASTPointer<ElementaryTypeName> _type
):
PrimaryExpression(_id, _location),
m_type(_type)
m_type(std::move(_type))
{
}
void accept(ASTVisitor& _visitor) override;
@ -2081,10 +2082,10 @@ public:
int64_t _id,
SourceLocation const& _location,
Token _token,
ASTPointer<ASTString> const& _value,
ASTPointer<ASTString> _value,
SubDenomination _sub = SubDenomination::None
):
PrimaryExpression(_id, _location), m_token(_token), m_value(_value), m_subDenomination(_sub) {}
PrimaryExpression(_id, _location), m_token(_token), m_value(std::move(_value)), m_subDenomination(_sub) {}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;

View File

@ -34,6 +34,7 @@
#include <boost/algorithm/string/join.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <utility>
#include <vector>
#include <algorithm>
@ -45,7 +46,7 @@ namespace solidity::frontend
ASTJsonConverter::ASTJsonConverter(bool _legacy, map<string, unsigned> _sourceIndices):
m_legacy(_legacy),
m_sourceIndices(_sourceIndices)
m_sourceIndices(std::move(_sourceIndices))
{
}

View File

@ -23,9 +23,11 @@
#pragma once
#include <libsolidity/ast/AST.h>
#include <functional>
#include <string>
#include <vector>
#include <utility>
namespace solidity::frontend
{
@ -299,7 +301,7 @@ public:
SimpleASTVisitor(
std::function<bool(ASTNode const&)> _onVisit,
std::function<void(ASTNode const&)> _onEndVisit
): m_onVisit(_onVisit), m_onEndVisit(_onEndVisit) {}
): m_onVisit(std::move(_onVisit)), m_onEndVisit(std::move(_onEndVisit)) {}
protected:
bool visitNode(ASTNode const& _n) override { return m_onVisit ? m_onVisit(_n) : true; }
@ -329,7 +331,7 @@ public:
ASTReduce(
std::function<bool(ASTNode const&)> _onNode,
std::function<void(ASTNode const&, ASTNode const&)> _onEdge
): m_onNode(_onNode), m_onEdge(_onEdge)
): m_onNode(std::move(_onNode)), m_onEdge(std::move(_onEdge))
{
}

View File

@ -26,6 +26,8 @@
#include <liblangutil/SourceLocation.h>
#include <libyul/AsmDataForward.h>
#include <utility>
namespace solidity::frontend
{
@ -35,7 +37,7 @@ namespace solidity::frontend
class AsmJsonImporter
{
public:
explicit AsmJsonImporter(std::string _sourceName) : m_sourceName(_sourceName) {}
explicit AsmJsonImporter(std::string _sourceName) : m_sourceName(std::move(_sourceName)) {}
yul::Block createBlock(Json::Value const& _node);
private:

View File

@ -43,6 +43,7 @@
#include <boost/range/algorithm/copy.hpp>
#include <limits>
#include <utility>
using namespace std;
using namespace solidity;
@ -1253,8 +1254,8 @@ StringLiteralType::StringLiteralType(Literal const& _literal):
{
}
StringLiteralType::StringLiteralType(string const& _value):
m_value{_value}
StringLiteralType::StringLiteralType(string _value):
m_value{std::move(_value)}
{
}

View File

@ -38,6 +38,7 @@
#include <optional>
#include <set>
#include <string>
#include <utility>
namespace solidity::frontend
{
@ -92,8 +93,8 @@ class MemberList
public:
struct Member
{
Member(std::string const& _name, Type const* _type, Declaration const* _declaration = nullptr):
name(_name),
Member(std::string _name, Type const* _type, Declaration const* _declaration = nullptr):
name(std::move(_name)),
type(_type),
declaration(_declaration)
{
@ -106,7 +107,7 @@ public:
using MemberMap = std::vector<Member>;
explicit MemberList(MemberMap const& _members): m_memberTypes(_members) {}
explicit MemberList(MemberMap _members): m_memberTypes(std::move(_members)) {}
void combine(MemberList const& _other);
TypePointer memberType(std::string const& _name) const
@ -520,8 +521,8 @@ private:
class RationalNumberType: public Type
{
public:
explicit RationalNumberType(rational const& _value, Type const* _compatibleBytesType = nullptr):
m_value(_value), m_compatibleBytesType(_compatibleBytesType)
explicit RationalNumberType(rational _value, Type const* _compatibleBytesType = nullptr):
m_value(std::move(_value)), m_compatibleBytesType(_compatibleBytesType)
{}
Category category() const override { return Category::RationalNumber; }
@ -543,7 +544,7 @@ public:
/// @returns the smallest integer type that can hold the value or an empty pointer if not possible.
IntegerType const* integerType() const;
/// @returns the smallest fixed type that can hold the value or incurs the least precision loss,
/// @returns the smallest fixed type that can hold the value or incurs the least precision loss,
/// unless the value was truncated, then a suitable type will be chosen to indicate such event.
/// If the integer part does not fit, returns an empty pointer.
FixedPointType const* fixedPointType() const;
@ -582,7 +583,7 @@ class StringLiteralType: public Type
{
public:
explicit StringLiteralType(Literal const& _literal);
explicit StringLiteralType(std::string const& _value);
explicit StringLiteralType(std::string _value);
Category category() const override { return Category::StringLiteral; }
@ -744,11 +745,11 @@ public:
}
/// Constructor for a fixed-size array type ("type[20]")
ArrayType(DataLocation _location, Type const* _baseType, u256 const& _length):
ArrayType(DataLocation _location, Type const* _baseType, u256 _length):
ReferenceType(_location),
m_baseType(copyForLocationIfReference(_baseType)),
m_hasDynamicLength(false),
m_length(_length)
m_length(std::move(_length))
{}
Category category() const override { return Category::Array; }
@ -1131,8 +1132,8 @@ public:
/// Detailed constructor, use with care.
FunctionType(
TypePointers const& _parameterTypes,
TypePointers const& _returnParameterTypes,
TypePointers _parameterTypes,
TypePointers _returnParameterTypes,
strings _parameterNames = strings(),
strings _returnParameterNames = strings(),
Kind _kind = Kind::Internal,
@ -1144,10 +1145,10 @@ public:
bool _saltSet = false,
bool _bound = false
):
m_parameterTypes(_parameterTypes),
m_returnParameterTypes(_returnParameterTypes),
m_parameterNames(_parameterNames),
m_returnParameterNames(_returnParameterNames),
m_parameterTypes(std::move(_parameterTypes)),
m_returnParameterTypes(std::move(_returnParameterTypes)),
m_parameterNames(std::move(_parameterNames)),
m_returnParameterNames(std::move(_returnParameterNames)),
m_kind(_kind),
m_stateMutability(_stateMutability),
m_arbitraryParameters(_arbitraryParameters),

View File

@ -29,6 +29,7 @@
#include <memory>
#include <stdexcept>
#include <string>
#include <utility>
using namespace std;
using namespace solidity;
@ -38,10 +39,10 @@ using namespace solidity::frontend::smt;
SMTLib2Interface::SMTLib2Interface(
map<h256, string> const& _queryResponses,
ReadCallback::Callback const& _smtCallback
ReadCallback::Callback _smtCallback
):
m_queryResponses(_queryResponses),
m_smtCallback(_smtCallback)
m_smtCallback(std::move(_smtCallback))
{
reset();
}

View File

@ -39,7 +39,7 @@ class SMTLib2Interface: public SolverInterface, public boost::noncopyable
public:
explicit SMTLib2Interface(
std::map<util::h256, std::string> const& _queryResponses,
ReadCallback::Callback const& _smtCallback
ReadCallback::Callback _smtCallback
);
void reset() override;

View File

@ -68,6 +68,7 @@
#include <json/json.h>
#include <boost/algorithm/string.hpp>
#include <utility>
using namespace std;
using namespace solidity;
@ -79,8 +80,8 @@ using solidity::util::toHex;
static int g_compilerStackCounts = 0;
CompilerStack::CompilerStack(ReadCallback::Callback const& _readFile):
m_readFile{_readFile},
CompilerStack::CompilerStack(ReadCallback::Callback _readFile):
m_readFile{std::move(_readFile)},
m_enabledSMTSolvers{smt::SMTSolverChoice::All()},
m_generateIR{false},
m_generateEwasm{false},

View File

@ -108,7 +108,7 @@ public:
/// Creates a new compiler stack.
/// @param _readFile callback used to read files for import statements. Must return
/// and must not emit exceptions.
explicit CompilerStack(ReadCallback::Callback const& _readFile = ReadCallback::Callback());
explicit CompilerStack(ReadCallback::Callback _readFile = ReadCallback::Callback());
~CompilerStack();

View File

@ -591,7 +591,7 @@ boost::variant<StandardCompiler::InputsAndSettings, Json::Value> StandardCompile
));
else
{
ret.sources[sourceName] = result.responseOrErrorMessage;
ret.sources[sourceName] = result.responseOrErrorMessage;
found = true;
break;
}

View File

@ -24,8 +24,9 @@
#include <libsolidity/interface/CompilerStack.h>
#include <optional>
#include <boost/variant.hpp>
#include <optional>
#include <utility>
namespace solidity::frontend
{
@ -40,8 +41,8 @@ public:
/// Creates a new StandardCompiler.
/// @param _readFile callback used to read files for import statements. Must return
/// and must not emit exceptions.
explicit StandardCompiler(ReadCallback::Callback const& _readFile = ReadCallback::Callback()):
m_readFile(_readFile)
explicit StandardCompiler(ReadCallback::Callback _readFile = ReadCallback::Callback()):
m_readFile(std::move(_readFile))
{
}

View File

@ -47,6 +47,7 @@
#include <boost/multiprecision/cpp_int.hpp>
#include <map>
#include <utility>
#include <vector>
#include <functional>
#include <string>
@ -120,7 +121,7 @@ inline std::ostream& operator<<(std::ostream& os, bytes const& _bytes)
class ScopeGuard
{
public:
explicit ScopeGuard(std::function<void(void)> _f): m_f(_f) {}
explicit ScopeGuard(std::function<void(void)> _f): m_f(std::move(_f)) {}
~ScopeGuard() { m_f(); }
private:

View File

@ -34,6 +34,7 @@
#include <list>
#include <memory>
#include <optional>
#include <utility>
namespace solidity::langutil
{
@ -58,14 +59,14 @@ public:
AsmAnalysisInfo& _analysisInfo,
langutil::ErrorReporter& _errorReporter,
Dialect const& _dialect,
ExternalIdentifierAccess::Resolver const& _resolver = ExternalIdentifierAccess::Resolver(),
std::set<YulString> const& _dataNames = {}
ExternalIdentifierAccess::Resolver _resolver = ExternalIdentifierAccess::Resolver(),
std::set<YulString> _dataNames = {}
):
m_resolver(_resolver),
m_resolver(std::move(_resolver)),
m_info(_analysisInfo),
m_errorReporter(_errorReporter),
m_dialect(_dialect),
m_dataNames(_dataNames)
m_dataNames(std::move(_dataNames))
{
if (EVMDialect const* evmDialect = dynamic_cast<EVMDialect const*>(&m_dialect))
m_evmVersion = evmDialect->evmVersion();

View File

@ -29,6 +29,7 @@
#include <boost/range/adaptor/reversed.hpp>
#include <utility>
#include <variant>
using namespace std;
@ -100,7 +101,7 @@ CodeTransform::CodeTransform(
EVMDialect const& _dialect,
BuiltinContext& _builtinContext,
bool _evm15,
ExternalIdentifierAccess const& _identifierAccess,
ExternalIdentifierAccess _identifierAccess,
bool _useNamedLabelsForFunctions,
shared_ptr<Context> _context
):
@ -111,8 +112,8 @@ CodeTransform::CodeTransform(
m_allowStackOpt(_allowStackOpt),
m_evm15(_evm15),
m_useNamedLabelsForFunctions(_useNamedLabelsForFunctions),
m_identifierAccess(_identifierAccess),
m_context(_context)
m_identifierAccess(std::move(_identifierAccess)),
m_context(std::move(_context))
{
if (!m_context)
{

View File

@ -152,7 +152,7 @@ protected:
EVMDialect const& _dialect,
BuiltinContext& _builtinContext,
bool _evm15,
ExternalIdentifierAccess const& _identifierAccess,
ExternalIdentifierAccess _identifierAccess,
bool _useNamedLabelsForFunctions,
std::shared_ptr<Context> _context
);

View File

@ -31,6 +31,7 @@
#include <optional>
#include <set>
#include <utility>
namespace solidity::yul
{
@ -147,10 +148,10 @@ class BodyCopier: public ASTCopier
public:
BodyCopier(
NameDispenser& _nameDispenser,
std::map<YulString, YulString> const& _variableReplacements
std::map<YulString, YulString> _variableReplacements
):
m_nameDispenser(_nameDispenser),
m_variableReplacements(_variableReplacements)
m_variableReplacements(std::move(_variableReplacements))
{}
using ASTCopier::operator ();

View File

@ -31,10 +31,11 @@
#include <boost/program_options.hpp>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <iostream>
#include <queue>
#include <regex>
#include <utility>
#if defined(_WIN32)
#include <windows.h>
@ -71,7 +72,7 @@ struct TestStats
class TestFilter
{
public:
explicit TestFilter(string const& _filter): m_filter(_filter)
explicit TestFilter(string _filter): m_filter(std::move(_filter))
{
string filter{m_filter};
@ -97,14 +98,14 @@ public:
TestTool(
TestCreator _testCaseCreator,
TestOptions const& _options,
fs::path const& _path,
string const& _name
fs::path _path,
string _name
):
m_testCaseCreator(_testCaseCreator),
m_options(_options),
m_filter(TestFilter{_options.testFilter}),
m_path(_path),
m_name(_name)
m_path(std::move(_path)),
m_name(std::move(_name))
{}
enum class Result

View File

@ -8,7 +8,7 @@
solidity is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
@ -21,6 +21,7 @@
#include <liblangutil/SourceLocation.h>
#include <algorithm>
#include <utility>
namespace solidity::tools
{
@ -50,7 +51,7 @@ public:
:
m_location(_location),
m_source(_location.source->source()),
m_patch(_patch),
m_patch(std::move(_patch)),
m_level(_level) {}
~UpgradeChange() {}