aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-08-22 18:43:19 +0800
committerGitHub <noreply@github.com>2017-08-22 18:43:19 +0800
commitf874fc28d1cb657b6d4e04fa9d93bd8d061f30c4 (patch)
treefb0f04a445940004a8a45e03bc98d149c5cc71a7
parent2c2ae74217521aae93b9c7b058ce8687046c648c (diff)
parent9897c56b2cacf162f8fd41d60e91b7f71863f8d5 (diff)
downloaddexon-solidity-f874fc28d1cb657b6d4e04fa9d93bd8d061f30c4.tar.gz
dexon-solidity-f874fc28d1cb657b6d4e04fa9d93bd8d061f30c4.tar.zst
dexon-solidity-f874fc28d1cb657b6d4e04fa9d93bd8d061f30c4.zip
Merge pull request #2772 from ethereum/cppcheck
Improvements found by Cppcheck (const/static functions and explicit constructors)
-rw-r--r--libdevcore/Common.h2
-rw-r--r--libdevcore/CommonData.h3
-rw-r--r--libdevcore/FixedHash.h2
-rw-r--r--libevmasm/BlockDeduplicator.h2
-rw-r--r--libevmasm/CommonSubexpressionEliminator.h2
-rw-r--r--libevmasm/ConstantOptimiser.cpp10
-rw-r--r--libevmasm/ConstantOptimiser.h24
-rw-r--r--libevmasm/PathGasMeter.h2
-rw-r--r--liblll/CodeFragment.h4
-rw-r--r--liblll/CompilerState.cpp2
-rw-r--r--liblll/CompilerState.h2
-rw-r--r--libsolidity/ast/ASTJsonConverter.h6
-rw-r--r--libsolidity/ast/ASTPrinter.h2
-rw-r--r--libsolidity/codegen/ABIFunctions.h2
-rw-r--r--libsolidity/codegen/ArrayUtils.h2
-rw-r--r--libsolidity/codegen/Compiler.h6
-rw-r--r--libsolidity/codegen/CompilerContext.h4
-rw-r--r--libsolidity/codegen/CompilerUtils.h2
-rw-r--r--libsolidity/codegen/ContractCompiler.cpp2
-rw-r--r--libsolidity/codegen/ExpressionCompiler.cpp2
-rw-r--r--libsolidity/codegen/ExpressionCompiler.h2
-rw-r--r--libsolidity/inlineasm/AsmCodeGen.cpp4
-rw-r--r--libsolidity/inlineasm/AsmParser.h2
-rw-r--r--libsolidity/inlineasm/AsmPrinter.cpp2
-rw-r--r--libsolidity/inlineasm/AsmPrinter.h2
-rw-r--r--libsolidity/inlineasm/AsmScope.cpp2
-rw-r--r--libsolidity/inlineasm/AsmScope.h2
-rw-r--r--libsolidity/interface/CompilerStack.h2
-rw-r--r--libsolidity/interface/ErrorReporter.h2
-rw-r--r--libsolidity/interface/StandardCompiler.h2
-rw-r--r--libsolidity/parsing/Parser.cpp4
-rw-r--r--libsolidity/parsing/Parser.h2
-rw-r--r--libsolidity/parsing/ParserBase.h2
-rw-r--r--libsolidity/parsing/Scanner.h10
-rw-r--r--test/RPCSession.h2
35 files changed, 63 insertions, 62 deletions
diff --git a/libdevcore/Common.h b/libdevcore/Common.h
index d383e74d..9d6dd408 100644
--- a/libdevcore/Common.h
+++ b/libdevcore/Common.h
@@ -157,7 +157,7 @@ template <> inline u256 exp10<0>()
class ScopeGuard
{
public:
- ScopeGuard(std::function<void(void)> _f): m_f(_f) {}
+ explicit ScopeGuard(std::function<void(void)> _f): m_f(_f) {}
~ScopeGuard() { m_f(); }
private:
diff --git a/libdevcore/CommonData.h b/libdevcore/CommonData.h
index 6f40d7be..0321011e 100644
--- a/libdevcore/CommonData.h
+++ b/libdevcore/CommonData.h
@@ -184,7 +184,8 @@ template <class T>
inline std::vector<T> operator+(std::vector<T> const& _a, std::vector<T> const& _b)
{
std::vector<T> ret(_a);
- return ret += _b;
+ ret += _b;
+ return ret;
}
template <class T, class V>
diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h
index 5b1c7acf..1c37b675 100644
--- a/libdevcore/FixedHash.h
+++ b/libdevcore/FixedHash.h
@@ -59,7 +59,7 @@ public:
enum ConstructFromHashType { AlignLeft, AlignRight, FailIfDifferent };
/// Construct an empty hash.
- FixedHash() { m_data.fill(0); }
+ explicit FixedHash() { m_data.fill(0); }
/// Construct from another hash, filling with zeroes or cropping as necessary.
template <unsigned M> explicit FixedHash(FixedHash<M> const& _h, ConstructFromHashType _t = AlignLeft) { m_data.fill(0); unsigned c = std::min(M, N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _h[_t == AlignRight ? M - 1 - i : i]; }
diff --git a/libevmasm/BlockDeduplicator.h b/libevmasm/BlockDeduplicator.h
index 797c2476..5640984b 100644
--- a/libevmasm/BlockDeduplicator.h
+++ b/libevmasm/BlockDeduplicator.h
@@ -45,7 +45,7 @@ using AssemblyItems = std::vector<AssemblyItem>;
class BlockDeduplicator
{
public:
- BlockDeduplicator(AssemblyItems& _items): m_items(_items) {}
+ explicit BlockDeduplicator(AssemblyItems& _items): m_items(_items) {}
/// @returns true if something was changed
bool deduplicate();
/// @returns the tags that were replaced.
diff --git a/libevmasm/CommonSubexpressionEliminator.h b/libevmasm/CommonSubexpressionEliminator.h
index 83fc9732..f2473200 100644
--- a/libevmasm/CommonSubexpressionEliminator.h
+++ b/libevmasm/CommonSubexpressionEliminator.h
@@ -61,7 +61,7 @@ public:
using Id = ExpressionClasses::Id;
using StoreOperation = KnownState::StoreOperation;
- CommonSubexpressionEliminator(KnownState const& _state): m_initialState(_state), m_state(_state) {}
+ explicit CommonSubexpressionEliminator(KnownState const& _state): m_initialState(_state), m_state(_state) {}
/// 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.
diff --git a/libevmasm/ConstantOptimiser.cpp b/libevmasm/ConstantOptimiser.cpp
index 2ecbfa7f..2efd2dc9 100644
--- a/libevmasm/ConstantOptimiser.cpp
+++ b/libevmasm/ConstantOptimiser.cpp
@@ -124,7 +124,7 @@ void ConstantOptimisationMethod::replaceConstants(
_items = std::move(replaced);
}
-bigint LiteralMethod::gasNeeded()
+bigint LiteralMethod::gasNeeded() const
{
return combineGas(
simpleRunGas({Instruction::PUSH1}),
@@ -139,7 +139,7 @@ CodeCopyMethod::CodeCopyMethod(Params const& _params, u256 const& _value):
{
}
-bigint CodeCopyMethod::gasNeeded()
+bigint CodeCopyMethod::gasNeeded() const
{
return combineGas(
// Run gas: we ignore memory increase costs
@@ -151,7 +151,7 @@ bigint CodeCopyMethod::gasNeeded()
);
}
-AssemblyItems CodeCopyMethod::execute(Assembly& _assembly)
+AssemblyItems CodeCopyMethod::execute(Assembly& _assembly) const
{
bytes data = toBigEndian(m_value);
AssemblyItems actualCopyRoutine = copyRoutine();
@@ -159,7 +159,7 @@ AssemblyItems CodeCopyMethod::execute(Assembly& _assembly)
return actualCopyRoutine;
}
-AssemblyItems const& CodeCopyMethod::copyRoutine() const
+AssemblyItems const& CodeCopyMethod::copyRoutine()
{
AssemblyItems static copyRoutine{
u256(0),
@@ -282,7 +282,7 @@ bool ComputeMethod::checkRepresentation(u256 const& _value, AssemblyItems const&
return stack.size() == 1 && stack.front() == _value;
}
-bigint ComputeMethod::gasNeeded(AssemblyItems const& _routine)
+bigint ComputeMethod::gasNeeded(AssemblyItems const& _routine) const
{
size_t numExps = count(_routine.begin(), _routine.end(), Instruction::EXP);
return combineGas(
diff --git a/libevmasm/ConstantOptimiser.h b/libevmasm/ConstantOptimiser.h
index 85bdabac..82982e25 100644
--- a/libevmasm/ConstantOptimiser.h
+++ b/libevmasm/ConstantOptimiser.h
@@ -63,11 +63,11 @@ public:
explicit ConstantOptimisationMethod(Params const& _params, u256 const& _value):
m_params(_params), m_value(_value) {}
- virtual bigint gasNeeded() = 0;
+ virtual bigint gasNeeded() const = 0;
/// Executes the method, potentially appending to the assembly and returns a vector of
/// assembly items the constant should be relpaced with in one sweep.
/// If the vector is empty, the constants will not be deleted.
- virtual AssemblyItems execute(Assembly& _assembly) = 0;
+ virtual AssemblyItems execute(Assembly& _assembly) const = 0;
protected:
size_t dataSize() const { return std::max<size_t>(1, dev::bytesRequired(m_value)); }
@@ -84,7 +84,7 @@ protected:
bigint const& _runGas,
bigint const& _repeatedDataGas,
bigint const& _uniqueDataGas
- )
+ ) const
{
// _runGas is not multiplied by _multiplicity because the runs are "per opcode"
return m_params.runs * _runGas + m_params.multiplicity * _repeatedDataGas + _uniqueDataGas;
@@ -106,8 +106,8 @@ class LiteralMethod: public ConstantOptimisationMethod
public:
explicit LiteralMethod(Params const& _params, u256 const& _value):
ConstantOptimisationMethod(_params, _value) {}
- virtual bigint gasNeeded() override;
- virtual AssemblyItems execute(Assembly&) override { return AssemblyItems{}; }
+ virtual bigint gasNeeded() const override;
+ virtual AssemblyItems execute(Assembly&) const override { return AssemblyItems{}; }
};
/**
@@ -117,11 +117,11 @@ class CodeCopyMethod: public ConstantOptimisationMethod
{
public:
explicit CodeCopyMethod(Params const& _params, u256 const& _value);
- virtual bigint gasNeeded() override;
- virtual AssemblyItems execute(Assembly& _assembly) override;
+ virtual bigint gasNeeded() const override;
+ virtual AssemblyItems execute(Assembly& _assembly) const override;
protected:
- AssemblyItems const& copyRoutine() const;
+ static AssemblyItems const& copyRoutine();
};
/**
@@ -141,8 +141,8 @@ public:
);
}
- virtual bigint gasNeeded() override { return gasNeeded(m_routine); }
- virtual AssemblyItems execute(Assembly&) override
+ virtual bigint gasNeeded() const override { return gasNeeded(m_routine); }
+ virtual AssemblyItems execute(Assembly&) const override
{
return m_routine;
}
@@ -151,8 +151,8 @@ protected:
/// Tries to recursively find a way to compute @a _value.
AssemblyItems findRepresentation(u256 const& _value);
/// Recomputes the value from the calculated representation and checks for correctness.
- bool checkRepresentation(u256 const& _value, AssemblyItems const& _routine);
- bigint gasNeeded(AssemblyItems const& _routine);
+ static bool checkRepresentation(u256 const& _value, AssemblyItems const& _routine);
+ bigint gasNeeded(AssemblyItems const& _routine) const;
/// Counter for the complexity of optimization, will stop when it reaches zero.
size_t m_maxSteps = 10000;
diff --git a/libevmasm/PathGasMeter.h b/libevmasm/PathGasMeter.h
index 0a0fe5d0..4826eac2 100644
--- a/libevmasm/PathGasMeter.h
+++ b/libevmasm/PathGasMeter.h
@@ -50,7 +50,7 @@ struct GasPath
class PathGasMeter
{
public:
- PathGasMeter(AssemblyItems const& _items);
+ explicit PathGasMeter(AssemblyItems const& _items);
GasMeter::GasConsumption estimateMax(size_t _startIndex, std::shared_ptr<KnownState> const& _state);
diff --git a/liblll/CodeFragment.h b/liblll/CodeFragment.h
index 6622de3e..95d21563 100644
--- a/liblll/CodeFragment.h
+++ b/liblll/CodeFragment.h
@@ -50,8 +50,8 @@ public:
private:
void finalise(CompilerState const& _cs);
- template <class T> void error() const { BOOST_THROW_EXCEPTION(T() ); }
- template <class T> void error(std::string const& reason) const {
+ template <class T> static void error() { BOOST_THROW_EXCEPTION(T() ); }
+ template <class T> static void error(std::string const& reason) {
auto err = T();
err << errinfo_comment(reason);
BOOST_THROW_EXCEPTION(err);
diff --git a/liblll/CompilerState.cpp b/liblll/CompilerState.cpp
index 9701e16b..d53dec7e 100644
--- a/liblll/CompilerState.cpp
+++ b/liblll/CompilerState.cpp
@@ -30,7 +30,7 @@ CompilerState::CompilerState()
{
}
-CodeFragment const& CompilerState::getDef(std::string const& _s)
+CodeFragment const& CompilerState::getDef(std::string const& _s) const
{
if (defs.count(_s))
return defs.at(_s);
diff --git a/liblll/CompilerState.h b/liblll/CompilerState.h
index c29d3b7d..96a0246d 100644
--- a/liblll/CompilerState.h
+++ b/liblll/CompilerState.h
@@ -40,7 +40,7 @@ struct CompilerState
{
CompilerState();
- CodeFragment const& getDef(std::string const& _s);
+ CodeFragment const& getDef(std::string const& _s) const;
void populateStandard();
unsigned stackSize = 128;
diff --git a/libsolidity/ast/ASTJsonConverter.h b/libsolidity/ast/ASTJsonConverter.h
index 70e260db..186607ce 100644
--- a/libsolidity/ast/ASTJsonConverter.h
+++ b/libsolidity/ast/ASTJsonConverter.h
@@ -119,7 +119,7 @@ private:
);
std::string sourceLocationToString(SourceLocation const& _location) const;
std::string namePathToString(std::vector<ASTString> const& _namePath) const;
- Json::Value idOrNull(ASTNode const* _pt)
+ static Json::Value idOrNull(ASTNode const* _pt)
{
return _pt ? Json::Value(nodeId(*_pt)) : Json::nullValue;
}
@@ -134,12 +134,12 @@ private:
std::string literalTokenKind(Token::Value _token);
std::string type(Expression const& _expression);
std::string type(VariableDeclaration const& _varDecl);
- int nodeId(ASTNode const& _node)
+ static int nodeId(ASTNode const& _node)
{
return _node.id();
}
template<class Container>
- Json::Value getContainerIds(Container const& container)
+ static Json::Value getContainerIds(Container const& container)
{
Json::Value tmp(Json::arrayValue);
for (auto const& element: container)
diff --git a/libsolidity/ast/ASTPrinter.h b/libsolidity/ast/ASTPrinter.h
index 4a37f17f..193f9296 100644
--- a/libsolidity/ast/ASTPrinter.h
+++ b/libsolidity/ast/ASTPrinter.h
@@ -146,7 +146,7 @@ private:
std::string m_source;
ASTNode const* m_ast;
GasEstimator::ASTGasConsumption m_gasCosts;
- std::ostream* m_ostream;
+ std::ostream* m_ostream = nullptr;
};
}
diff --git a/libsolidity/codegen/ABIFunctions.h b/libsolidity/codegen/ABIFunctions.h
index 76f4b467..e43e2323 100644
--- a/libsolidity/codegen/ABIFunctions.h
+++ b/libsolidity/codegen/ABIFunctions.h
@@ -162,7 +162,7 @@ private:
std::string createFunction(std::string const& _name, std::function<std::string()> const& _creator);
/// @returns the size of the static part of the encoding of the given types.
- size_t headSize(TypePointers const& _targetTypes);
+ static size_t headSize(TypePointers const& _targetTypes);
/// Map from function name to code for a multi-use function.
std::map<std::string, std::string> m_requestedFunctions;
diff --git a/libsolidity/codegen/ArrayUtils.h b/libsolidity/codegen/ArrayUtils.h
index 806fbea7..f3ddc4ee 100644
--- a/libsolidity/codegen/ArrayUtils.h
+++ b/libsolidity/codegen/ArrayUtils.h
@@ -40,7 +40,7 @@ using TypePointer = std::shared_ptr<Type const>;
class ArrayUtils
{
public:
- ArrayUtils(CompilerContext& _context): m_context(_context) {}
+ explicit ArrayUtils(CompilerContext& _context): m_context(_context) {}
/// Copies an array to an array in storage. The arrays can be of different types only if
/// their storage representation is the same.
diff --git a/libsolidity/codegen/Compiler.h b/libsolidity/codegen/Compiler.h
index eef078c1..8c63ea9c 100644
--- a/libsolidity/codegen/Compiler.h
+++ b/libsolidity/codegen/Compiler.h
@@ -51,9 +51,9 @@ public:
ContractDefinition const& _contract,
std::map<ContractDefinition const*, eth::Assembly const*> const& _contracts
);
- eth::Assembly const& assembly() { return m_context.assembly(); }
- eth::LinkerObject assembledObject() { return m_context.assembledObject(); }
- eth::LinkerObject runtimeObject() { return m_context.assembledRuntimeObject(m_runtimeSub); }
+ eth::Assembly const& assembly() const { return m_context.assembly(); }
+ eth::LinkerObject assembledObject() const { return m_context.assembledObject(); }
+ eth::LinkerObject runtimeObject() const { return m_context.assembledRuntimeObject(m_runtimeSub); }
/// @arg _sourceCodes is the map of input files to source code strings
/// @arg _inJsonFromat shows whether the out should be in Json format
Json::Value streamAssembly(std::ostream& _stream, StringMap const& _sourceCodes = StringMap(), bool _inJsonFormat = false) const
diff --git a/libsolidity/codegen/CompilerContext.h b/libsolidity/codegen/CompilerContext.h
index 583360ea..96cbf6c1 100644
--- a/libsolidity/codegen/CompilerContext.h
+++ b/libsolidity/codegen/CompilerContext.h
@@ -208,8 +208,8 @@ public:
return m_asm->stream(_stream, "", _sourceCodes, _inJsonFormat);
}
- eth::LinkerObject const& assembledObject() { return m_asm->assemble(); }
- eth::LinkerObject const& assembledRuntimeObject(size_t _subIndex) { return m_asm->sub(_subIndex).assemble(); }
+ eth::LinkerObject const& assembledObject() const { return m_asm->assemble(); }
+ eth::LinkerObject const& assembledRuntimeObject(size_t _subIndex) const { return m_asm->sub(_subIndex).assemble(); }
/**
* Helper class to pop the visited nodes stack when a scope closes
diff --git a/libsolidity/codegen/CompilerUtils.h b/libsolidity/codegen/CompilerUtils.h
index 09427788..18b70250 100644
--- a/libsolidity/codegen/CompilerUtils.h
+++ b/libsolidity/codegen/CompilerUtils.h
@@ -33,7 +33,7 @@ class Type; // forward
class CompilerUtils
{
public:
- CompilerUtils(CompilerContext& _context): m_context(_context) {}
+ explicit CompilerUtils(CompilerContext& _context): m_context(_context) {}
/// Stores the initial value of the free-memory-pointer at its position;
void initialiseFreeMemoryPointer();
diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp
index 29a22fae..e53f1b94 100644
--- a/libsolidity/codegen/ContractCompiler.cpp
+++ b/libsolidity/codegen/ContractCompiler.cpp
@@ -45,7 +45,7 @@ using namespace dev::solidity;
class StackHeightChecker
{
public:
- StackHeightChecker(CompilerContext const& _context):
+ explicit StackHeightChecker(CompilerContext const& _context):
m_context(_context), stackHeight(m_context.stackHeight()) {}
void check() { solAssert(m_context.stackHeight() == stackHeight, std::string("I sense a disturbance in the stack: ") + std::to_string(m_context.stackHeight()) + " vs " + std::to_string(stackHeight)); }
private:
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp
index 55d35c44..639bfc32 100644
--- a/libsolidity/codegen/ExpressionCompiler.cpp
+++ b/libsolidity/codegen/ExpressionCompiler.cpp
@@ -1811,7 +1811,7 @@ void ExpressionCompiler::setLValueToStorageItem(Expression const& _expression)
setLValue<StorageItem>(_expression, *_expression.annotation().type);
}
-bool ExpressionCompiler::cleanupNeededForOp(Type::Category _type, Token::Value _op)
+bool ExpressionCompiler::cleanupNeededForOp(Type::Category _type, Token::Value _op) const
{
if (Token::isCompareOp(_op) || Token::isShiftOp(_op))
return true;
diff --git a/libsolidity/codegen/ExpressionCompiler.h b/libsolidity/codegen/ExpressionCompiler.h
index 3b8cf1c6..5f6c3d64 100644
--- a/libsolidity/codegen/ExpressionCompiler.h
+++ b/libsolidity/codegen/ExpressionCompiler.h
@@ -119,7 +119,7 @@ private:
/// @returns true if the operator applied to the given type requires a cleanup prior to the
/// operation.
- bool cleanupNeededForOp(Type::Category _type, Token::Value _op);
+ bool cleanupNeededForOp(Type::Category _type, Token::Value _op) const;
/// @returns the CompilerUtils object containing the current context.
CompilerUtils utils();
diff --git a/libsolidity/inlineasm/AsmCodeGen.cpp b/libsolidity/inlineasm/AsmCodeGen.cpp
index 74743737..6d0c0255 100644
--- a/libsolidity/inlineasm/AsmCodeGen.cpp
+++ b/libsolidity/inlineasm/AsmCodeGen.cpp
@@ -52,7 +52,7 @@ using namespace dev::solidity::assembly;
class EthAssemblyAdapter: public julia::AbstractAssembly
{
public:
- EthAssemblyAdapter(eth::Assembly& _assembly):
+ explicit EthAssemblyAdapter(eth::Assembly& _assembly):
m_assembly(_assembly)
{
}
@@ -127,7 +127,7 @@ public:
}
private:
- LabelID assemblyTagToIdentifier(eth::AssemblyItem const& _tag) const
+ static LabelID assemblyTagToIdentifier(eth::AssemblyItem const& _tag)
{
u256 id = _tag.data();
solAssert(id <= std::numeric_limits<LabelID>::max(), "Tag id too large.");
diff --git a/libsolidity/inlineasm/AsmParser.h b/libsolidity/inlineasm/AsmParser.h
index a48a3393..e46d1732 100644
--- a/libsolidity/inlineasm/AsmParser.h
+++ b/libsolidity/inlineasm/AsmParser.h
@@ -45,7 +45,7 @@ public:
protected:
/// Creates an inline assembly node with the given source location.
- template <class T> T createWithLocation(SourceLocation const& _loc = SourceLocation())
+ template <class T> T createWithLocation(SourceLocation const& _loc = SourceLocation()) const
{
T r;
r.location = _loc;
diff --git a/libsolidity/inlineasm/AsmPrinter.cpp b/libsolidity/inlineasm/AsmPrinter.cpp
index 4f96a3e9..47ede91d 100644
--- a/libsolidity/inlineasm/AsmPrinter.cpp
+++ b/libsolidity/inlineasm/AsmPrinter.cpp
@@ -209,7 +209,7 @@ string AsmPrinter::operator()(Block const& _block)
return "{\n " + body + "\n}";
}
-string AsmPrinter::appendTypeName(std::string const& _type)
+string AsmPrinter::appendTypeName(std::string const& _type) const
{
if (m_julia)
return ":" + _type;
diff --git a/libsolidity/inlineasm/AsmPrinter.h b/libsolidity/inlineasm/AsmPrinter.h
index f57dddc8..66520632 100644
--- a/libsolidity/inlineasm/AsmPrinter.h
+++ b/libsolidity/inlineasm/AsmPrinter.h
@@ -53,7 +53,7 @@ public:
std::string operator()(assembly::Block const& _block);
private:
- std::string appendTypeName(std::string const& _type);
+ std::string appendTypeName(std::string const& _type) const;
bool m_julia = false;
};
diff --git a/libsolidity/inlineasm/AsmScope.cpp b/libsolidity/inlineasm/AsmScope.cpp
index 315d5953..64d5bd9a 100644
--- a/libsolidity/inlineasm/AsmScope.cpp
+++ b/libsolidity/inlineasm/AsmScope.cpp
@@ -70,7 +70,7 @@ Scope::Identifier* Scope::lookup(string const& _name)
return nullptr;
}
-bool Scope::exists(string const& _name)
+bool Scope::exists(string const& _name) const
{
if (identifiers.count(_name))
return true;
diff --git a/libsolidity/inlineasm/AsmScope.h b/libsolidity/inlineasm/AsmScope.h
index cc240565..447d6490 100644
--- a/libsolidity/inlineasm/AsmScope.h
+++ b/libsolidity/inlineasm/AsmScope.h
@@ -107,7 +107,7 @@ struct Scope
}
/// @returns true if the name exists in this scope or in super scopes (also searches
/// across function and assembly boundaries).
- bool exists(std::string const& _name);
+ bool exists(std::string const& _name) const;
/// @returns the number of variables directly registered inside the scope.
size_t numberOfVariables() const;
diff --git a/libsolidity/interface/CompilerStack.h b/libsolidity/interface/CompilerStack.h
index 54e3e23f..bb0f4126 100644
--- a/libsolidity/interface/CompilerStack.h
+++ b/libsolidity/interface/CompilerStack.h
@@ -88,7 +88,7 @@ public:
m_errorReporter(m_errorList) {}
/// @returns the list of errors that occured during parsing and type checking.
- ErrorList const& errors() { return m_errorReporter.errors(); }
+ ErrorList const& errors() const { return m_errorReporter.errors(); }
/// @returns the current state.
State state() const { return m_stackState; }
diff --git a/libsolidity/interface/ErrorReporter.h b/libsolidity/interface/ErrorReporter.h
index 12f4e8df..241d6b43 100644
--- a/libsolidity/interface/ErrorReporter.h
+++ b/libsolidity/interface/ErrorReporter.h
@@ -36,7 +36,7 @@ class ErrorReporter
{
public:
- ErrorReporter(ErrorList& _errors):
+ explicit ErrorReporter(ErrorList& _errors):
m_errorList(_errors) { }
ErrorReporter& operator=(ErrorReporter const& _errorReporter);
diff --git a/libsolidity/interface/StandardCompiler.h b/libsolidity/interface/StandardCompiler.h
index dfaf88cd..d9787a40 100644
--- a/libsolidity/interface/StandardCompiler.h
+++ b/libsolidity/interface/StandardCompiler.h
@@ -40,7 +40,7 @@ public:
/// Creates a new StandardCompiler.
/// @param _readFile callback to used to read files for import statements. Must return
/// and must not emit exceptions.
- StandardCompiler(ReadFile::Callback const& _readFile = ReadFile::Callback())
+ explicit StandardCompiler(ReadFile::Callback const& _readFile = ReadFile::Callback())
: m_compilerStack(_readFile), m_readFile(_readFile)
{
}
diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp
index d3a6aa45..7455cbca 100644
--- a/libsolidity/parsing/Parser.cpp
+++ b/libsolidity/parsing/Parser.cpp
@@ -40,7 +40,7 @@ namespace solidity
class Parser::ASTNodeFactory
{
public:
- ASTNodeFactory(Parser const& _parser):
+ explicit ASTNodeFactory(Parser const& _parser):
m_parser(_parser), m_location(_parser.position(), -1, _parser.sourceName()) {}
ASTNodeFactory(Parser const& _parser, ASTPointer<ASTNode> const& _childNode):
m_parser(_parser), m_location(_childNode->location()) {}
@@ -69,7 +69,7 @@ private:
class Parser::RecursionGuard
{
public:
- RecursionGuard(Parser& _parser):
+ explicit RecursionGuard(Parser& _parser):
m_parser(_parser)
{
m_parser.increaseRecursionDepth();
diff --git a/libsolidity/parsing/Parser.h b/libsolidity/parsing/Parser.h
index 5e6f3ef6..0f74880c 100644
--- a/libsolidity/parsing/Parser.h
+++ b/libsolidity/parsing/Parser.h
@@ -35,7 +35,7 @@ class Scanner;
class Parser: public ParserBase
{
public:
- Parser(ErrorReporter& _errorReporter): ParserBase(_errorReporter) {}
+ explicit Parser(ErrorReporter& _errorReporter): ParserBase(_errorReporter) {}
ASTPointer<SourceUnit> parse(std::shared_ptr<Scanner> const& _scanner);
diff --git a/libsolidity/parsing/ParserBase.h b/libsolidity/parsing/ParserBase.h
index 5b03ab5e..48733fc1 100644
--- a/libsolidity/parsing/ParserBase.h
+++ b/libsolidity/parsing/ParserBase.h
@@ -36,7 +36,7 @@ class Scanner;
class ParserBase
{
public:
- ParserBase(ErrorReporter& errorReporter): m_errorReporter(errorReporter) {}
+ explicit ParserBase(ErrorReporter& errorReporter): m_errorReporter(errorReporter) {}
std::shared_ptr<std::string const> const& sourceName() const;
diff --git a/libsolidity/parsing/Scanner.h b/libsolidity/parsing/Scanner.h
index d6b48c6f..0adaa6fd 100644
--- a/libsolidity/parsing/Scanner.h
+++ b/libsolidity/parsing/Scanner.h
@@ -75,7 +75,7 @@ public:
int position() const { return m_position; }
bool isPastEndOfInput(size_t _charsForward = 0) const { return (m_position + _charsForward) >= m_source.size(); }
char get(size_t _charsForward = 0) const { return m_source[m_position + _charsForward]; }
- char advanceAndGet(size_t _chars=1);
+ char advanceAndGet(size_t _chars = 1);
char rollback(size_t _amount);
void reset() { m_position = 0; }
@@ -118,11 +118,11 @@ public:
///@name Information about the current token
/// @returns the current token
- Token::Value currentToken()
+ Token::Value currentToken() const
{
return m_currentToken.token;
}
- ElementaryTypeNameToken currentElementaryTypeNameToken()
+ ElementaryTypeNameToken currentElementaryTypeNameToken() const
{
unsigned firstSize;
unsigned secondSize;
@@ -219,8 +219,8 @@ private:
bool scanEscape();
/// Return the current source position.
- int sourcePos() { return m_source.position(); }
- bool isSourcePastEndOfInput() { return m_source.isPastEndOfInput(); }
+ int sourcePos() const { return m_source.position(); }
+ bool isSourcePastEndOfInput() const { return m_source.isPastEndOfInput(); }
TokenDesc m_skippedComment; // desc for current skipped comment
TokenDesc m_nextSkippedComment; // desc for next skiped comment
diff --git a/test/RPCSession.h b/test/RPCSession.h
index f7fdd86e..558cb99f 100644
--- a/test/RPCSession.h
+++ b/test/RPCSession.h
@@ -124,7 +124,7 @@ public:
std::string const& accountCreateIfNotExists(size_t _id);
private:
- RPCSession(std::string const& _path);
+ explicit RPCSession(std::string const& _path);
inline std::string quote(std::string const& _arg) { return "\"" + _arg + "\""; }
/// Parse std::string replacing keywords to values