Merge pull request #5998 from ethereum/codingStyleCheck

More coding style checks
This commit is contained in:
chriseth 2019-02-13 17:36:34 +01:00 committed by GitHub
commit c5879589af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
54 changed files with 645 additions and 615 deletions

View File

@ -123,7 +123,7 @@ static inline void keccakf(void* state) {
FOR(i, 1, len, S); \ FOR(i, 1, len, S); \
} }
#define mkapply_sd(NAME, S) \ #define mkapply_sd(NAME, S) \
static inline void NAME(const uint8_t* src, \ static inline void NAME(uint8_t const* src, \
uint8_t* dst, \ uint8_t* dst, \
size_t len) { \ size_t len) { \
FOR(i, 1, len, S); \ FOR(i, 1, len, S); \

View File

@ -77,7 +77,7 @@ bool isWellFormed(unsigned char byte1, unsigned char byte2)
return false; return false;
} }
bool validateUTF8(const unsigned char *_input, size_t _length, size_t& _invalidPosition) bool validateUTF8(unsigned char const* _input, size_t _length, size_t& _invalidPosition)
{ {
bool valid = true; bool valid = true;
size_t i = 0; size_t i = 0;

View File

@ -1,48 +1,48 @@
/* /*
This file is part of solidity. * This file is part of solidity.
*
solidity is free software: you can redistribute it and/or modify * solidity is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. * (at your option) any later version.
*
solidity is distributed in the hope that it will be useful, * solidity is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of * 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. * GNU General Public License for more details.
*
You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
along with solidity. If not, see <http://www.gnu.org/licenses/>. * along with solidity. If not, see <http://www.gnu.org/licenses/>.
*
This file is derived from the file "scanner.cc", which was part of the * This file is derived from the file "scanner.cc", which was part of the
V8 project. The original copyright header follows: * V8 project. The original copyright header follows:
*
Copyright 2006-2012, the V8 project authors. All rights reserved. * Copyright 2006-2012, the V8 project authors. All rights reserved.
Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are * modification, are permitted provided that the following conditions are
met: * met:
*
* Redistributions of source code must retain the above copyright * * Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above * * Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following * copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided * disclaimer in the documentation and/or other materials provided
with the distribution. * with the distribution.
* Neither the name of Google Inc. nor the names of its * * Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived * contributors may be used to endorse or promote products derived
from this software without specific prior written permission. * from this software without specific prior written permission.
*
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
/** /**
* @author Christian <c@ethdev.com> * @author Christian <c@ethdev.com>
@ -85,8 +85,10 @@ string CharStream::lineAtPosition(int _position) const
lineStart = 0; lineStart = 0;
else else
lineStart++; lineStart++;
return m_source.substr(lineStart, min(m_source.find('\n', lineStart), return m_source.substr(
m_source.size()) - lineStart); lineStart,
min(m_source.find('\n', lineStart), m_source.size()) - lineStart
);
} }
tuple<int, int> CharStream::translatePositionToLineColumn(int _position) const tuple<int, int> CharStream::translatePositionToLineColumn(int _position) const

View File

@ -1,48 +1,48 @@
/* /*
This file is part of solidity. * This file is part of solidity.
*
solidity is free software: you can redistribute it and/or modify * solidity is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. * (at your option) any later version.
*
solidity is distributed in the hope that it will be useful, * solidity is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of * 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. * GNU General Public License for more details.
*
You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
along with solidity. If not, see <http://www.gnu.org/licenses/>. * along with solidity. If not, see <http://www.gnu.org/licenses/>.
*
This file is derived from the file "scanner.h", which was part of the * This file is derived from the file "scanner.h", which was part of the
V8 project. The original copyright header follows: * V8 project. The original copyright header follows:
*
Copyright 2006-2012, the V8 project authors. All rights reserved. * Copyright 2006-2012, the V8 project authors. All rights reserved.
Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are * modification, are permitted provided that the following conditions are
met: * met:
*
* Redistributions of source code must retain the above copyright * * Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above * * Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following * copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided * disclaimer in the documentation and/or other materials provided
with the distribution. * with the distribution.
* Neither the name of Google Inc. nor the names of its * * Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived * contributors may be used to endorse or promote products derived
from this software without specific prior written permission. * from this software without specific prior written permission.
*
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
/** /**
* @author Christian <c@ethdev.com> * @author Christian <c@ethdev.com>

View File

@ -1,48 +1,48 @@
/* /*
This file is part of solidity. * This file is part of solidity.
*
solidity is free software: you can redistribute it and/or modify * solidity is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. * (at your option) any later version.
*
solidity is distributed in the hope that it will be useful, * solidity is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of * 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. * GNU General Public License for more details.
*
You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
along with solidity. If not, see <http://www.gnu.org/licenses/>. * along with solidity. If not, see <http://www.gnu.org/licenses/>.
*
This file is derived from the file "scanner.cc", which was part of the * This file is derived from the file "scanner.cc", which was part of the
V8 project. The original copyright header follows: * V8 project. The original copyright header follows:
*
Copyright 2006-2012, the V8 project authors. All rights reserved. * Copyright 2006-2012, the V8 project authors. All rights reserved.
Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are * modification, are permitted provided that the following conditions are
met: * met:
*
* Redistributions of source code must retain the above copyright * * Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above * * Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following * copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided * disclaimer in the documentation and/or other materials provided
with the distribution. * with the distribution.
* Neither the name of Google Inc. nor the names of its * * Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived * contributors may be used to endorse or promote products derived
from this software without specific prior written permission. * from this software without specific prior written permission.
*
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
/** /**
* @author Christian <c@ethdev.com> * @author Christian <c@ethdev.com>
@ -69,9 +69,10 @@ bool isDecimalDigit(char c)
} }
bool isHexDigit(char c) bool isHexDigit(char c)
{ {
return isDecimalDigit(c) return
|| ('a' <= c && c <= 'f') isDecimalDigit(c) ||
|| ('A' <= c && c <= 'F'); ('a' <= c && c <= 'f') ||
('A' <= c && c <= 'F');
} }
bool isLineTerminator(char c) bool isLineTerminator(char c)
{ {

View File

@ -1,48 +1,48 @@
/* /*
This file is part of solidity. * This file is part of solidity.
*
solidity is free software: you can redistribute it and/or modify * solidity is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. * (at your option) any later version.
*
solidity is distributed in the hope that it will be useful, * solidity is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of * 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. * GNU General Public License for more details.
*
You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
along with solidity. If not, see <http://www.gnu.org/licenses/>. * along with solidity. If not, see <http://www.gnu.org/licenses/>.
*
This file is derived from the file "scanner.h", which was part of the * This file is derived from the file "scanner.h", which was part of the
V8 project. The original copyright header follows: * V8 project. The original copyright header follows:
*
Copyright 2006-2012, the V8 project authors. All rights reserved. * Copyright 2006-2012, the V8 project authors. All rights reserved.
Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are * modification, are permitted provided that the following conditions are
met: * met:
*
* Redistributions of source code must retain the above copyright * * Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above * * Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following * copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided * disclaimer in the documentation and/or other materials provided
with the distribution. * with the distribution.
* Neither the name of Google Inc. nor the names of its * * Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived * contributors may be used to endorse or promote products derived
from this software without specific prior written permission. * from this software without specific prior written permission.
*
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
/** /**
* @author Christian <c@ethdev.com> * @author Christian <c@ethdev.com>

View File

@ -32,7 +32,8 @@ namespace dev
namespace solidity namespace solidity
{ {
/** Occurrence of a variable in a block of control flow. /**
* Occurrence of a variable in a block of control flow.
* Stores the declaration of the referenced variable, the * Stores the declaration of the referenced variable, the
* kind of the occurrence and possibly the node at which * kind of the occurrence and possibly the node at which
* it occurred. * it occurred.
@ -85,7 +86,8 @@ private:
ASTNode const* m_occurrence = nullptr; ASTNode const* m_occurrence = nullptr;
}; };
/** Node of the Control Flow Graph. /**
* Node of the Control Flow Graph.
* The control flow is a directed graph connecting control flow blocks. * The control flow is a directed graph connecting control flow blocks.
* An arc between two nodes indicates that the control flow can possibly * An arc between two nodes indicates that the control flow can possibly
* move from its start node to its end node during execution. * move from its start node to its end node during execution.

View File

@ -113,9 +113,13 @@ bool ASTPrinter::visit(ParameterList const& _node)
bool ASTPrinter::visit(FunctionDefinition const& _node) bool ASTPrinter::visit(FunctionDefinition const& _node)
{ {
writeLine("FunctionDefinition \"" + _node.name() + "\"" + writeLine(
"FunctionDefinition \"" +
_node.name() +
"\"" +
(_node.isPublic() ? " - public" : "") + (_node.isPublic() ? " - public" : "") +
(_node.stateMutability() == StateMutability::View ? " - const" : "")); (_node.stateMutability() == StateMutability::View ? " - const" : "")
);
printSourcePart(_node); printSourcePart(_node);
return goDeeper(); return goDeeper();
} }
@ -305,8 +309,12 @@ bool ASTPrinter::visit(TupleExpression const& _node)
bool ASTPrinter::visit(UnaryOperation const& _node) bool ASTPrinter::visit(UnaryOperation const& _node)
{ {
writeLine(string("UnaryOperation (") + (_node.isPrefixOperation() ? "prefix" : "postfix") + writeLine(
") " + TokenTraits::toString(_node.getOperator())); string("UnaryOperation (") +
(_node.isPrefixOperation() ? "prefix" : "postfix") +
") " +
TokenTraits::toString(_node.getOperator())
);
printType(_node); printType(_node);
printSourcePart(_node); printSourcePart(_node);
return goDeeper(); return goDeeper();

View File

@ -1380,7 +1380,7 @@ string StringLiteralType::richIdentifier() const
return "t_stringliteral_" + toHex(keccak256(m_value).asBytes()); return "t_stringliteral_" + toHex(keccak256(m_value).asBytes());
} }
bool StringLiteralType::operator==(const Type& _other) const bool StringLiteralType::operator==(Type const& _other) const
{ {
if (_other.category() != category()) if (_other.category() != category())
return false; return false;
@ -1463,7 +1463,7 @@ TypeResult FixedBytesType::binaryOperatorResult(Token _operator, TypePointer con
return TypePointer(); return TypePointer();
} }
MemberList::MemberMap FixedBytesType::nativeMembers(const ContractDefinition*) const MemberList::MemberMap FixedBytesType::nativeMembers(ContractDefinition const*) const
{ {
return MemberList::MemberMap{MemberList::Member{"length", make_shared<IntegerType>(8)}}; return MemberList::MemberMap{MemberList::Member{"length", make_shared<IntegerType>(8)}};
} }
@ -1611,7 +1611,7 @@ string ReferenceType::identifierLocationSuffix() const
return id; return id;
} }
BoolResult ArrayType::isImplicitlyConvertibleTo(const Type& _convertTo) const BoolResult ArrayType::isImplicitlyConvertibleTo(Type const& _convertTo) const
{ {
if (_convertTo.category() != category()) if (_convertTo.category() != category())
return false; return false;
@ -1651,7 +1651,7 @@ BoolResult ArrayType::isImplicitlyConvertibleTo(const Type& _convertTo) const
} }
} }
BoolResult ArrayType::isExplicitlyConvertibleTo(const Type& _convertTo) const BoolResult ArrayType::isExplicitlyConvertibleTo(Type const& _convertTo) const
{ {
if (isImplicitlyConvertibleTo(_convertTo)) if (isImplicitlyConvertibleTo(_convertTo))
return true; return true;
@ -2010,7 +2010,7 @@ vector<tuple<VariableDeclaration const*, u256, unsigned>> ContractType::stateVar
return variablesAndOffsets; return variablesAndOffsets;
} }
BoolResult StructType::isImplicitlyConvertibleTo(const Type& _convertTo) const BoolResult StructType::isImplicitlyConvertibleTo(Type const& _convertTo) const
{ {
if (_convertTo.category() != category()) if (_convertTo.category() != category())
return false; return false;
@ -3298,7 +3298,7 @@ MemberList::MemberMap TypeType::nativeMembers(ContractDefinition const* _current
return members; return members;
} }
ModifierType::ModifierType(const ModifierDefinition& _modifier) ModifierType::ModifierType(ModifierDefinition const& _modifier)
{ {
TypePointers params; TypePointers params;
params.reserve(_modifier.parameters().size()); params.reserve(_modifier.parameters().size());
@ -3327,8 +3327,12 @@ bool ModifierType::operator==(Type const& _other) const
return false; return false;
auto typeCompare = [](TypePointer const& _a, TypePointer const& _b) -> bool { return *_a == *_b; }; auto typeCompare = [](TypePointer const& _a, TypePointer const& _b) -> bool { return *_a == *_b; };
if (!equal(m_parameterTypes.cbegin(), m_parameterTypes.cend(), if (!equal(
other.m_parameterTypes.cbegin(), typeCompare)) m_parameterTypes.cbegin(),
m_parameterTypes.cend(),
other.m_parameterTypes.cbegin(),
typeCompare
))
return false; return false;
return true; return true;
} }

View File

@ -707,7 +707,7 @@ public:
BoolResult isImplicitlyConvertibleTo(Type const& _convertTo) const override; BoolResult isImplicitlyConvertibleTo(Type const& _convertTo) const override;
BoolResult isExplicitlyConvertibleTo(Type const& _convertTo) const override; BoolResult isExplicitlyConvertibleTo(Type const& _convertTo) const override;
std::string richIdentifier() const override; std::string richIdentifier() const override;
bool operator==(const Type& _other) const override; bool operator==(Type const& _other) const override;
unsigned calldataEncodedSize(bool _padded) const override; unsigned calldataEncodedSize(bool _padded) const override;
bool isDynamicallySized() const override { return m_hasDynamicLength; } bool isDynamicallySized() const override { return m_hasDynamicLength; }
bool isDynamicallyEncoded() const override; bool isDynamicallyEncoded() const override;
@ -823,7 +823,7 @@ public:
Category category() const override { return Category::Struct; } Category category() const override { return Category::Struct; }
explicit StructType(StructDefinition const& _struct, DataLocation _location = DataLocation::Storage): explicit StructType(StructDefinition const& _struct, DataLocation _location = DataLocation::Storage):
ReferenceType(_location), m_struct(_struct) {} ReferenceType(_location), m_struct(_struct) {}
BoolResult isImplicitlyConvertibleTo(const Type& _convertTo) const override; BoolResult isImplicitlyConvertibleTo(Type const& _convertTo) const override;
std::string richIdentifier() const override; std::string richIdentifier() const override;
bool operator==(Type const& _other) const override; bool operator==(Type const& _other) const override;
unsigned calldataEncodedSize(bool _padded) const override; unsigned calldataEncodedSize(bool _padded) const override;

View File

@ -1262,7 +1262,7 @@ string ABIFunctions::abiDecodingFunction(Type const& _type, bool _fromMemory, bo
return abiDecodingFunctionValueType(_type, _fromMemory); return abiDecodingFunctionValueType(_type, _fromMemory);
} }
string ABIFunctions::abiDecodingFunctionValueType(const Type& _type, bool _fromMemory) string ABIFunctions::abiDecodingFunctionValueType(Type const& _type, bool _fromMemory)
{ {
TypePointer decodingType = _type.decodingType(); TypePointer decodingType = _type.decodingType();
solAssert(decodingType, ""); solAssert(decodingType, "");

View File

@ -934,8 +934,11 @@ void ArrayUtils::clearStorageLoop(TypePointer const& _type) const
eth::AssemblyItem loopStart = _context.appendJumpToNew(); eth::AssemblyItem loopStart = _context.appendJumpToNew();
_context << loopStart; _context << loopStart;
// check for loop condition // check for loop condition
_context << Instruction::DUP1 << Instruction::DUP3 _context <<
<< Instruction::GT << Instruction::ISZERO; Instruction::DUP1 <<
Instruction::DUP3 <<
Instruction::GT <<
Instruction::ISZERO;
eth::AssemblyItem zeroLoopEnd = _context.newTag(); eth::AssemblyItem zeroLoopEnd = _context.newTag();
_context.appendConditionalJumpTo(zeroLoopEnd); _context.appendConditionalJumpTo(zeroLoopEnd);
// delete // delete

View File

@ -129,8 +129,10 @@ void CompilerContext::appendMissingLowLevelFunctions()
} }
} }
void CompilerContext::addVariable(VariableDeclaration const& _declaration, void CompilerContext::addVariable(
unsigned _offsetToCurrent) VariableDeclaration const& _declaration,
unsigned _offsetToCurrent
)
{ {
solAssert(m_asm->deposit() >= 0 && unsigned(m_asm->deposit()) >= _offsetToCurrent, ""); solAssert(m_asm->deposit() >= 0 && unsigned(m_asm->deposit()) >= _offsetToCurrent, "");
unsigned sizeOnStack = _declaration.annotation().type->sizeOnStack(); unsigned sizeOnStack = _declaration.annotation().type->sizeOnStack();
@ -265,7 +267,7 @@ unsigned CompilerContext::currentToBaseStackOffset(unsigned _offset) const
return m_asm->deposit() - _offset - 1; return m_asm->deposit() - _offset - 1;
} }
pair<u256, unsigned> CompilerContext::storageLocationOfVariable(const Declaration& _declaration) const pair<u256, unsigned> CompilerContext::storageLocationOfVariable(Declaration const& _declaration) const
{ {
auto it = m_stateVariables.find(&_declaration); auto it = m_stateVariables.find(&_declaration);
solAssert(it != m_stateVariables.end(), "Variable not found in storage."); solAssert(it != m_stateVariables.end(), "Variable not found in storage.");

View File

@ -267,7 +267,7 @@ private:
std::vector<ContractDefinition const*>::const_iterator _searchStart std::vector<ContractDefinition const*>::const_iterator _searchStart
); );
/// @returns an iterator to the contract directly above the given contract. /// @returns an iterator to the contract directly above the given contract.
std::vector<ContractDefinition const*>::const_iterator superContract(const ContractDefinition &_contract) const; std::vector<ContractDefinition const*>::const_iterator superContract(ContractDefinition const& _contract) const;
/// Updates source location set in the assembly. /// Updates source location set in the assembly.
void updateSourceLocation(); void updateSourceLocation();
@ -291,7 +291,7 @@ private:
Declaration const* nextFunctionToCompile() const; Declaration const* nextFunctionToCompile() const;
/// Informs the queue that we are about to compile the given function, i.e. removes /// Informs the queue that we are about to compile the given function, i.e. removes
/// the function from the queue of functions to compile. /// the function from the queue of functions to compile.
void startFunction(const Declaration &_function); void startFunction(Declaration const& _function);
/// Labels pointing to the entry points of functions. /// Labels pointing to the entry points of functions.
std::map<Declaration const*, eth::AssemblyItem> m_entryLabels; std::map<Declaration const*, eth::AssemblyItem> m_entryLabels;

View File

@ -1310,8 +1310,10 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess)
utils().leftShiftNumberOnStack(224); utils().leftShiftNumberOnStack(224);
} }
else else
solAssert(!!_memberAccess.expression().annotation().type->memberType(member), solAssert(
"Invalid member access to function."); !!_memberAccess.expression().annotation().type->memberType(member),
"Invalid member access to function."
);
break; break;
case Type::Category::Magic: case Type::Category::Magic:
// we can ignore the kind of magic and only look at the name of the member // we can ignore the kind of magic and only look at the name of the member

View File

@ -71,7 +71,7 @@ public:
void appendStateVariableAccessor(VariableDeclaration const& _varDecl); void appendStateVariableAccessor(VariableDeclaration const& _varDecl);
/// Appends code for a Constant State Variable accessor function /// Appends code for a Constant State Variable accessor function
void appendConstStateVariableAccessor(const VariableDeclaration& _varDecl); void appendConstStateVariableAccessor(VariableDeclaration const& _varDecl);
private: private:
bool visit(Conditional const& _condition) override; bool visit(Conditional const& _condition) override;

View File

@ -127,7 +127,7 @@ private:
YulStringRepository::Handle m_handle{ 0, YulStringRepository::emptyHash() }; YulStringRepository::Handle m_handle{ 0, YulStringRepository::emptyHash() };
}; };
inline YulString operator "" _yulstring(const char *_string, std::size_t _size) inline YulString operator "" _yulstring(char const* _string, std::size_t _size)
{ {
return YulString(std::string(_string, _size)); return YulString(std::string(_string, _size));
} }

View File

@ -17,14 +17,16 @@ fi
FORMATERROR=$( FORMATERROR=$(
( (
git grep -nIE "\<(if|for)\(" -- '*.h' '*.cpp' git grep -nIE "\<(if|for)\(" -- '*.h' '*.cpp' # no space after "if" or "for"
git grep -nIE "\<if\>\s*\(.*\)\s*\{\s*$" -- '*.h' '*.cpp' git grep -nIE "\<if\>\s*\(.*\)\s*\{\s*$" -- '*.h' '*.cpp' # "{\n" on same line as "if" / "for"
git grep -nIE "\(const " -- '*.h' '*.cpp' # const on left side of type
git grep -nIE "^ [^*]|[^*] | [^*]" -- '*.h' '*.cpp' # uses spaces for indentation or mixes spaces and tabs
) | egrep -v "^[a-zA-Z\./]*:[0-9]*:\s*\/(\/|\*)" | egrep -v "^test/" ) | egrep -v "^[a-zA-Z\./]*:[0-9]*:\s*\/(\/|\*)" | egrep -v "^test/"
) )
if [[ "$FORMATERROR" != "" ]] if [[ "$FORMATERROR" != "" ]]
then then
echo "Error: Format error for if/for:" | tee -a $ERROR_LOG echo "Coding style error:" | tee -a $ERROR_LOG
echo "$FORMATERROR" | tee -a $ERROR_LOG echo "$FORMATERROR" | tee -a $ERROR_LOG
exit 1 exit 1
fi fi

View File

@ -593,7 +593,7 @@ at standard output or in files in the output directory, if specified.
Imports are automatically read from the filesystem, but it is also possible to Imports are automatically read from the filesystem, but it is also possible to
remap paths using the context:prefix=path syntax. remap paths using the context:prefix=path syntax.
Example: Example:
solc --bin -o /tmp/solcoutput dapp-bin=/usr/local/lib/dapp-bin contract.sol solc --bin -o /tmp/solcoutput dapp-bin=/usr/local/lib/dapp-bin contract.sol
Allowed options)", Allowed options)",
po::options_description::m_default_line_length, po::options_description::m_default_line_length,
@ -927,14 +927,18 @@ bool CommandLineInterface::processInput()
} }
catch (InternalCompilerError const& _exception) catch (InternalCompilerError const& _exception)
{ {
serr() << "Internal compiler error during compilation:" << endl serr() <<
<< boost::diagnostic_information(_exception); "Internal compiler error during compilation:" <<
endl <<
boost::diagnostic_information(_exception);
return false; return false;
} }
catch (UnimplementedFeatureError const& _exception) catch (UnimplementedFeatureError const& _exception)
{ {
serr() << "Unimplemented feature:" << endl serr() <<
<< boost::diagnostic_information(_exception); "Unimplemented feature:" <<
endl <<
boost::diagnostic_information(_exception);
return false; return false;
} }
catch (Error const& _error) catch (Error const& _error)

View File

@ -137,7 +137,7 @@ string IPCSocket::sendRequest(string const& _req)
#endif #endif
} }
RPCSession& RPCSession::instance(const string& _path) RPCSession& RPCSession::instance(string const& _path)
{ {
static RPCSession session(_path); static RPCSession session(_path);
BOOST_REQUIRE_EQUAL(session.m_ipcSocket.path(), _path); BOOST_REQUIRE_EQUAL(session.m_ipcSocket.path(), _path);
@ -358,7 +358,7 @@ string const& RPCSession::accountCreateIfNotExists(size_t _id)
return m_accounts[_id]; return m_accounts[_id];
} }
RPCSession::RPCSession(const string& _path): RPCSession::RPCSession(string const& _path):
m_ipcSocket(_path) m_ipcSocket(_path)
{ {
accountCreate(); accountCreate();

View File

@ -544,7 +544,7 @@ BOOST_AUTO_TEST_CASE(keyword_is_reserved)
"unchecked" "unchecked"
}; };
for (const auto& keyword: keywords) for (auto const& keyword: keywords)
{ {
auto text = std::string("contract ") + keyword + " {}"; auto text = std::string("contract ") + keyword + " {}";
CHECK_PARSE_ERROR(text.c_str(), string("Expected identifier but got reserved keyword '") + keyword + "'"); CHECK_PARSE_ERROR(text.c_str(), string("Expected identifier but got reserved keyword '") + keyword + "'");