diff --git a/libevmasm/CommonSubexpressionEliminator.h b/libevmasm/CommonSubexpressionEliminator.h index 0e6f6ee36..ce9c898ee 100644 --- a/libevmasm/CommonSubexpressionEliminator.h +++ b/libevmasm/CommonSubexpressionEliminator.h @@ -69,8 +69,8 @@ public: /// Feeds AssemblyItems into the eliminator and @returns the iterator pointing at the first /// item that must be fed into a new instance of the eliminator. /// @param _msizeImportant if false, do not consider modification of MSIZE a side-effect - template - _AssemblyItemIterator feedItems(_AssemblyItemIterator _iterator, _AssemblyItemIterator _end, bool _msizeImportant); + template + AssemblyItemIterator feedItems(AssemblyItemIterator _iterator, AssemblyItemIterator _end, bool _msizeImportant); /// @returns the resulting items after optimization. AssemblyItems getOptimizedItems(); @@ -169,10 +169,10 @@ private: std::map m_targetStack; }; -template -_AssemblyItemIterator CommonSubexpressionEliminator::feedItems( - _AssemblyItemIterator _iterator, - _AssemblyItemIterator _end, +template +AssemblyItemIterator CommonSubexpressionEliminator::feedItems( + AssemblyItemIterator _iterator, + AssemblyItemIterator _end, bool _msizeImportant ) { diff --git a/libevmasm/KnownState.cpp b/libevmasm/KnownState.cpp index b6198e994..7e447a9a1 100644 --- a/libevmasm/KnownState.cpp +++ b/libevmasm/KnownState.cpp @@ -179,7 +179,7 @@ KnownState::StoreOperation KnownState::feedItem(AssemblyItem const& _item, bool /// Helper function for KnownState::reduceToCommonKnowledge, removes everything from /// _this which is not in or not equal to the value in _other. -template void intersect(_Mapping& _this, _Mapping const& _other) +template void intersect(Mapping& _this, Mapping const& _other) { for (auto it = _this.begin(); it != _this.end();) if (_other.count(it->first) && _other.at(it->first) == it->second) diff --git a/libsolidity/analysis/NameAndTypeResolver.cpp b/libsolidity/analysis/NameAndTypeResolver.cpp index 76c388f3f..3643c6401 100644 --- a/libsolidity/analysis/NameAndTypeResolver.cpp +++ b/libsolidity/analysis/NameAndTypeResolver.cpp @@ -405,13 +405,13 @@ void NameAndTypeResolver::linearizeBaseContracts(ContractDefinition& _contract) _contract.annotation().contractDependencies.insert(result.begin() + 1, result.end()); } -template -vector<_T const*> NameAndTypeResolver::cThreeMerge(list>& _toMerge) +template +vector NameAndTypeResolver::cThreeMerge(list>& _toMerge) { // returns true iff _candidate appears only as last element of the lists - auto appearsOnlyAtHead = [&](_T const* _candidate) -> bool + auto appearsOnlyAtHead = [&](T const* _candidate) -> bool { - for (list<_T const*> const& bases: _toMerge) + for (list const& bases: _toMerge) { solAssert(!bases.empty(), ""); if (find(++bases.begin(), bases.end(), _candidate) != bases.end()) @@ -420,9 +420,9 @@ vector<_T const*> NameAndTypeResolver::cThreeMerge(list>& _toMer return true; }; // returns the next candidate to append to the linearized list or nullptr on failure - auto nextCandidate = [&]() -> _T const* + auto nextCandidate = [&]() -> T const* { - for (list<_T const*> const& bases: _toMerge) + for (list const& bases: _toMerge) { solAssert(!bases.empty(), ""); if (appearsOnlyAtHead(bases.front())) @@ -431,7 +431,7 @@ vector<_T const*> NameAndTypeResolver::cThreeMerge(list>& _toMer return nullptr; }; // removes the given contract from all lists - auto removeCandidate = [&](_T const* _candidate) + auto removeCandidate = [&](T const* _candidate) { for (auto it = _toMerge.begin(); it != _toMerge.end();) { @@ -443,13 +443,13 @@ vector<_T const*> NameAndTypeResolver::cThreeMerge(list>& _toMer } }; - _toMerge.remove_if([](list<_T const*> const& _bases) { return _bases.empty(); }); - vector<_T const*> result; + _toMerge.remove_if([](list const& _bases) { return _bases.empty(); }); + vector result; while (!_toMerge.empty()) { - _T const* candidate = nextCandidate(); + T const* candidate = nextCandidate(); if (!candidate) - return vector<_T const*>(); + return vector(); result.push_back(candidate); removeCandidate(candidate); } diff --git a/libsolidity/analysis/NameAndTypeResolver.h b/libsolidity/analysis/NameAndTypeResolver.h index b8ae2fefb..dc4d32bb9 100644 --- a/libsolidity/analysis/NameAndTypeResolver.h +++ b/libsolidity/analysis/NameAndTypeResolver.h @@ -122,8 +122,8 @@ private: void linearizeBaseContracts(ContractDefinition& _contract); /// Computes the C3-merge of the given list of lists of bases. /// @returns the linearized vector or an empty vector if linearization is not possible. - template - static std::vector<_T const*> cThreeMerge(std::list>& _toMerge); + template + static std::vector cThreeMerge(std::list>& _toMerge); /// Maps nodes declaring a scope to scopes, i.e. ContractDefinition and FunctionDeclaration, /// where nullptr denotes the global scope. Note that structs are not scope since they do diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index c0c29be7d..336c221c6 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -88,8 +88,8 @@ public: } /// @returns a copy of the vector containing only the nodes which derive from T. - template - static std::vector<_T const*> filteredNodes(std::vector> const& _nodes); + template + static std::vector filteredNodes(std::vector> const& _nodes); /// Returns the source code location of this node. SourceLocation const& location() const { return m_location; } @@ -121,12 +121,12 @@ private: SourceLocation m_location; }; -template -std::vector<_T const*> ASTNode::filteredNodes(std::vector> const& _nodes) +template +std::vector ASTNode::filteredNodes(std::vector> const& _nodes) { - std::vector<_T const*> ret; + std::vector ret; for (auto const& n: _nodes) - if (auto const* nt = dynamic_cast<_T const*>(n.get())) + if (auto const* nt = dynamic_cast(n.get())) ret.push_back(nt); return ret; } diff --git a/libsolidity/codegen/ABIFunctions.h b/libsolidity/codegen/ABIFunctions.h index a0b8333df..ce3efe6ea 100644 --- a/libsolidity/codegen/ABIFunctions.h +++ b/libsolidity/codegen/ABIFunctions.h @@ -204,7 +204,7 @@ private: /// @param _fromMemory if decoding from memory instead of from calldata /// @param _forUseOnStack if the decoded value is stored on stack or in memory. std::string abiDecodingFunction( - Type const& _Type, + Type const& _type, bool _fromMemory, bool _forUseOnStack ); diff --git a/libsolidity/codegen/ExpressionCompiler.h b/libsolidity/codegen/ExpressionCompiler.h index 33fb2696f..f75fbc8ab 100644 --- a/libsolidity/codegen/ExpressionCompiler.h +++ b/libsolidity/codegen/ExpressionCompiler.h @@ -125,8 +125,8 @@ private: void setLValueToStorageItem(Expression const& _expression); /// Sets the current LValue to a new LValue constructed from the arguments. /// Also retrieves the value if it was not requested by @a _expression. - template - void setLValue(Expression const& _expression, _Arguments const&... _arguments); + template + void setLValue(Expression const& _expression, Arguments const&... _arguments); /// @returns true if the operator applied to the given type requires a cleanup prior to the /// operation. @@ -143,11 +143,11 @@ private: }; -template -void ExpressionCompiler::setLValue(Expression const& _expression, _Arguments const&... _arguments) +template +void ExpressionCompiler::setLValue(Expression const& _expression, Arguments const&... _arguments) { solAssert(!m_currentLValue, "Current LValue not reset before trying to set new one."); - std::unique_ptr<_LValueType> lvalue = std::make_unique<_LValueType>(m_context, _arguments...); + std::unique_ptr lvalue = std::make_unique(m_context, _arguments...); if (_expression.annotation().lValueRequested) m_currentLValue = move(lvalue); else diff --git a/libsolutil/Assertions.h b/libsolutil/Assertions.h index c0c330835..1c5a14008 100644 --- a/libsolutil/Assertions.h +++ b/libsolutil/Assertions.h @@ -40,12 +40,12 @@ namespace solidity::util /// Assertion that throws an exception containing the given description if it is not met. /// Use it as assertThrow(1 == 1, ExceptionType, "Mathematics is wrong."); /// Do NOT supply an exception object as the second parameter. -#define assertThrow(_condition, _ExceptionType, _description) \ +#define assertThrow(_condition, _exceptionType, _description) \ do \ { \ if (!(_condition)) \ ::boost::throw_exception( \ - _ExceptionType() << \ + _exceptionType() << \ ::solidity::util::errinfo_comment(_description) << \ ::boost::throw_function(ETH_FUNC) << \ ::boost::throw_file(__FILE__) << \ diff --git a/libsolutil/CommonData.h b/libsolutil/CommonData.h index 5afb65470..f969ad212 100644 --- a/libsolutil/CommonData.h +++ b/libsolutil/CommonData.h @@ -249,14 +249,14 @@ inline void toBigEndian(T _val, Out& o_out) } /// Converts a big-endian byte-stream represented on a templated collection to a templated integer value. -/// @a _In will typically be either std::string or bytes. +/// @a In will typically be either std::string or bytes. /// @a T will typically by unsigned, u160, u256 or bigint. -template -inline T fromBigEndian(_In const& _bytes) +template +inline T fromBigEndian(In const& _bytes) { T ret = (T)0; for (auto i: _bytes) - ret = (T)((ret << 8) | (uint8_t)(typename std::make_unsigned::type)i); + ret = (T)((ret << 8) | (uint8_t)(typename std::make_unsigned::type)i); return ret; } inline bytes toBigEndian(u256 _val) { bytes ret(32); toBigEndian(_val, ret); return ret; } diff --git a/libsolutil/CommonIO.cpp b/libsolutil/CommonIO.cpp index 0eca85720..ec6c33538 100644 --- a/libsolutil/CommonIO.cpp +++ b/libsolutil/CommonIO.cpp @@ -40,11 +40,11 @@ using namespace solidity::util; namespace { -template -inline _T readFile(std::string const& _file) +template +inline T readFile(std::string const& _file) { - _T ret; - size_t const c_elementSize = sizeof(typename _T::value_type); + T ret; + size_t const c_elementSize = sizeof(typename T::value_type); std::ifstream is(_file, std::ifstream::binary); if (!is) return ret; diff --git a/libsolutil/CommonIO.h b/libsolutil/CommonIO.h index 15291df33..be763c42f 100644 --- a/libsolutil/CommonIO.h +++ b/libsolutil/CommonIO.h @@ -42,8 +42,8 @@ std::string readStandardInput(); int readStandardInputChar(); /// Converts arbitrary value to string representation using std::stringstream. -template -std::string toString(_T const& _t) +template +std::string toString(T const& _t) { std::ostringstream o; o << _t; diff --git a/libsolutil/vector_ref.h b/libsolutil/vector_ref.h index 2c98bce25..3bb71f35e 100644 --- a/libsolutil/vector_ref.h +++ b/libsolutil/vector_ref.h @@ -16,63 +16,63 @@ namespace solidity::util /** * A modifiable reference to an existing object or vector in memory. */ -template +template class vector_ref { public: - using value_type = _T; - using element_type = _T; - using mutable_value_type = typename std::conditional::value, typename std::remove_const<_T>::type, _T>::type; - using string_type = typename std::conditional::value, std::string const, std::string>::type; - using vector_type = typename std::conditional::value, std::vector::type> const, std::vector<_T>>::type; - using iterator = _T*; - using const_iterator = _T const*; + using value_type = T; + using element_type = T; + using mutable_value_type = typename std::conditional::value, typename std::remove_const::type, T>::type; + using string_type = typename std::conditional::value, std::string const, std::string>::type; + using vector_type = typename std::conditional::value, std::vector::type> const, std::vector>::type; + using iterator = T*; + using const_iterator = T const*; static_assert(std::is_pod::value, "vector_ref can only be used with PODs due to its low-level treatment of data."); vector_ref(): m_data(nullptr), m_count(0) {} /// Creates a new vector_ref to point to @a _count elements starting at @a _data. - vector_ref(_T* _data, size_t _count): m_data(_data), m_count(_count) {} + vector_ref(T* _data, size_t _count): m_data(_data), m_count(_count) {} /// Creates a new vector_ref pointing to the data part of a string (given as pointer). - vector_ref(string_type* _data): m_data(reinterpret_cast<_T*>(_data->data())), m_count(_data->size() / sizeof(_T)) {} + vector_ref(string_type* _data): m_data(reinterpret_cast(_data->data())), m_count(_data->size() / sizeof(T)) {} /// Creates a new vector_ref pointing to the data part of a string (given as reference). vector_ref(string_type& _data): vector_ref(&_data) {} /// Creates a new vector_ref pointing to the data part of a vector (given as pointer). vector_ref(vector_type* _data): m_data(_data->data()), m_count(_data->size()) {} explicit operator bool() const { return m_data && m_count; } - std::vector toBytes() const { return std::vector(reinterpret_cast(m_data), reinterpret_cast(m_data) + m_count * sizeof(_T)); } - std::string toString() const { return std::string((char const*)m_data, ((char const*)m_data) + m_count * sizeof(_T)); } + std::vector toBytes() const { return std::vector(reinterpret_cast(m_data), reinterpret_cast(m_data) + m_count * sizeof(T)); } + std::string toString() const { return std::string((char const*)m_data, ((char const*)m_data) + m_count * sizeof(T)); } - template explicit operator vector_ref<_T2>() const { assert(m_count * sizeof(_T) / sizeof(_T2) * sizeof(_T2) / sizeof(_T) == m_count); return vector_ref<_T2>(reinterpret_cast<_T2*>(m_data), m_count * sizeof(_T) / sizeof(_T2)); } - operator vector_ref<_T const>() const { return vector_ref<_T const>(m_data, m_count); } + template explicit operator vector_ref() const { assert(m_count * sizeof(T) / sizeof(T2) * sizeof(T2) / sizeof(T) == m_count); return vector_ref(reinterpret_cast(m_data), m_count * sizeof(T) / sizeof(T2)); } + operator vector_ref() const { return vector_ref(m_data, m_count); } - _T* data() const { return m_data; } + T* data() const { return m_data; } /// @returns the number of elements referenced (not necessarily number of bytes). size_t size() const { return m_count; } bool empty() const { return !m_count; } /// @returns a new vector_ref which is a shifted and shortened view of the original data. /// If this goes out of bounds in any way, returns an empty vector_ref. /// If @a _count is ~size_t(0), extends the view to the end of the data. - vector_ref<_T> cropped(size_t _begin, size_t _count) const { if (m_data && _begin <= m_count && _count <= m_count && _begin + _count <= m_count) return vector_ref<_T>(m_data + _begin, _count == ~size_t(0) ? m_count - _begin : _count); else return vector_ref<_T>(); } + vector_ref cropped(size_t _begin, size_t _count) const { if (m_data && _begin <= m_count && _count <= m_count && _begin + _count <= m_count) return vector_ref(m_data + _begin, _count == ~size_t(0) ? m_count - _begin : _count); else return vector_ref(); } /// @returns a new vector_ref which is a shifted view of the original data (not going beyond it). - vector_ref<_T> cropped(size_t _begin) const { if (m_data && _begin <= m_count) return vector_ref<_T>(m_data + _begin, m_count - _begin); else return vector_ref<_T>(); } + vector_ref cropped(size_t _begin) const { if (m_data && _begin <= m_count) return vector_ref(m_data + _begin, m_count - _begin); else return vector_ref(); } - _T* begin() { return m_data; } - _T* end() { return m_data + m_count; } - _T const* begin() const { return m_data; } - _T const* end() const { return m_data + m_count; } + T* begin() { return m_data; } + T* end() { return m_data + m_count; } + T const* begin() const { return m_data; } + T const* end() const { return m_data + m_count; } - _T& operator[](size_t _i) { assert(m_data); assert(_i < m_count); return m_data[_i]; } - _T const& operator[](size_t _i) const { assert(m_data); assert(_i < m_count); return m_data[_i]; } + T& operator[](size_t _i) { assert(m_data); assert(_i < m_count); return m_data[_i]; } + T const& operator[](size_t _i) const { assert(m_data); assert(_i < m_count); return m_data[_i]; } - bool operator==(vector_ref<_T> const& _cmp) const { return m_data == _cmp.m_data && m_count == _cmp.m_count; } - bool operator!=(vector_ref<_T> const& _cmp) const { return !operator==(_cmp); } + bool operator==(vector_ref const& _cmp) const { return m_data == _cmp.m_data && m_count == _cmp.m_count; } + bool operator!=(vector_ref const& _cmp) const { return !operator==(_cmp); } void reset() { m_data = nullptr; m_count = 0; } private: - _T* m_data = nullptr; + T* m_data = nullptr; size_t m_count = 0; }; diff --git a/libyul/optimiser/BlockHasher.cpp b/libyul/optimiser/BlockHasher.cpp index a878db601..53d263f94 100644 --- a/libyul/optimiser/BlockHasher.cpp +++ b/libyul/optimiser/BlockHasher.cpp @@ -30,9 +30,9 @@ using namespace solidity::util; namespace { -static constexpr uint64_t compileTimeLiteralHash(char const* _literal, size_t _N) +static constexpr uint64_t compileTimeLiteralHash(char const* _literal, size_t _n) { - return (_N == 0) ? BlockHasher::fnvEmptyHash : (static_cast(_literal[0]) * BlockHasher::fnvPrime) ^ compileTimeLiteralHash(_literal + 1, _N - 1); + return (_n == 0) ? BlockHasher::fnvEmptyHash : (static_cast(_literal[0]) * BlockHasher::fnvPrime) ^ compileTimeLiteralHash(_literal + 1, _n - 1); } template diff --git a/test/ExecutionFramework.h b/test/ExecutionFramework.h index 40e12da94..6a3ffc0fb 100644 --- a/test/ExecutionFramework.h +++ b/test/ExecutionFramework.h @@ -179,8 +179,8 @@ public: return _padLeft ? padding + _value : _value + padding; } static bytes encode(std::string const& _value) { return encode(util::asBytes(_value), false); } - template - static bytes encode(std::vector<_T> const& _value) + template + static bytes encode(std::vector const& _value) { bytes ret; for (auto const& v: _value)