aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Parpart <christian@ethereum.org>2018-12-12 21:51:22 +0800
committerChristian Parpart <christian@ethereum.org>2018-12-19 18:26:42 +0800
commit62fe57479e7d8949e4ed2e0efb31238d5d8d6d0a (patch)
treec2592dc9a8a1abae524717c0d081e51bf1ed3c24
parentd10bae245ed441314c3bd6ecc74b2a1f3d060d12 (diff)
downloaddexon-solidity-62fe57479e7d8949e4ed2e0efb31238d5d8d6d0a.tar.gz
dexon-solidity-62fe57479e7d8949e4ed2e0efb31238d5d8d6d0a.tar.zst
dexon-solidity-62fe57479e7d8949e4ed2e0efb31238d5d8d6d0a.zip
make use of C++ `= default` constructor declarations as well as more non-static member initialization syntax.
-rw-r--r--libdevcore/IndentedWriter.h4
-rw-r--r--libevmasm/Assembly.h2
-rw-r--r--libevmasm/KnownState.cpp4
-rw-r--r--libevmasm/KnownState.h17
-rw-r--r--liblangutil/CharStream.h6
-rw-r--r--liblangutil/EVMVersion.h2
-rw-r--r--liblangutil/SourceReferenceExtractor.h25
-rw-r--r--liblll/CodeFragment.h2
-rw-r--r--libsolidity/analysis/ControlFlowGraph.h3
-rw-r--r--libsolidity/ast/ASTAnnotations.h4
-rw-r--r--libsolidity/ast/Types.h1
-rw-r--r--libsolidity/codegen/LValue.h2
-rw-r--r--libsolidity/parsing/Parser.cpp2
-rw-r--r--libsolidity/parsing/Parser.h7
-rw-r--r--libyul/Dialect.h2
-rw-r--r--libyul/Object.h2
-rw-r--r--libyul/YulString.h12
-rw-r--r--libyul/backends/evm/AbstractAssembly.h2
-rw-r--r--libyul/backends/evm/EVMAssembly.h2
-rw-r--r--libyul/backends/evm/EVMDialect.cpp2
-rw-r--r--libyul/optimiser/RedundantAssignEliminator.h2
-rw-r--r--solc/CommandLineInterface.h2
-rw-r--r--test/TestCase.h2
-rw-r--r--test/libsolidity/GasMeter.cpp1
-rw-r--r--test/libsolidity/SolidityABIJSON.cpp2
-rw-r--r--test/libsolidity/SolidityNatspecJSON.cpp2
-rw-r--r--test/libsolidity/SolidityOptimizer.cpp2
27 files changed, 51 insertions, 65 deletions
diff --git a/libdevcore/IndentedWriter.h b/libdevcore/IndentedWriter.h
index 4ddd87ed..563c4c96 100644
--- a/libdevcore/IndentedWriter.h
+++ b/libdevcore/IndentedWriter.h
@@ -34,8 +34,6 @@ DEV_SIMPLE_EXCEPTION(IndentedWriterError);
class IndentedWriter
{
public:
- explicit IndentedWriter(): m_lines(std::vector<Line>{{std::string(), 0}}) {}
-
// Returns the formatted output.
std::string format() const;
@@ -61,7 +59,7 @@ private:
unsigned indentation;
};
- std::vector<Line> m_lines;
+ std::vector<Line> m_lines{{std::string(), 0}};
};
}
diff --git a/libevmasm/Assembly.h b/libevmasm/Assembly.h
index d846b475..5dc6ef0e 100644
--- a/libevmasm/Assembly.h
+++ b/libevmasm/Assembly.h
@@ -45,8 +45,6 @@ using AssemblyPointer = std::shared_ptr<Assembly>;
class Assembly
{
public:
- Assembly() {}
-
AssemblyItem newTag() { assertThrow(m_usedTags < 0xffffffff, AssemblyException, ""); return AssemblyItem(Tag, m_usedTags++); }
AssemblyItem newPushTag() { assertThrow(m_usedTags < 0xffffffff, AssemblyException, ""); return AssemblyItem(PushTag, m_usedTags++); }
/// Returns a tag identified by the given name. Creates it if it does not yet exist.
diff --git a/libevmasm/KnownState.cpp b/libevmasm/KnownState.cpp
index a5546e61..d6cc5ddd 100644
--- a/libevmasm/KnownState.cpp
+++ b/libevmasm/KnownState.cpp
@@ -304,7 +304,7 @@ KnownState::StoreOperation KnownState::storeInStorage(
AssemblyItem item(Instruction::SSTORE, _location);
Id id = m_expressionClasses->find(item, {_slot, _value}, true, m_sequenceNumber);
- StoreOperation operation(StoreOperation::Storage, _slot, m_sequenceNumber, id);
+ StoreOperation operation{StoreOperation::Storage, _slot, m_sequenceNumber, id};
m_storageContent[_slot] = _value;
// increment a second time so that we get unique sequence numbers for writes
m_sequenceNumber++;
@@ -336,7 +336,7 @@ KnownState::StoreOperation KnownState::storeInMemory(Id _slot, Id _value, Source
AssemblyItem item(Instruction::MSTORE, _location);
Id id = m_expressionClasses->find(item, {_slot, _value}, true, m_sequenceNumber);
- StoreOperation operation(StoreOperation(StoreOperation::Memory, _slot, m_sequenceNumber, id));
+ StoreOperation operation{StoreOperation::Memory, _slot, m_sequenceNumber, id};
m_memoryContent[_slot] = _value;
// increment a second time so that we get unique sequence numbers for writes
m_sequenceNumber++;
diff --git a/libevmasm/KnownState.h b/libevmasm/KnownState.h
index 3ab1c4b1..3b5e9e7a 100644
--- a/libevmasm/KnownState.h
+++ b/libevmasm/KnownState.h
@@ -74,18 +74,13 @@ public:
struct StoreOperation
{
enum Target { Invalid, Memory, Storage };
- StoreOperation(): target(Invalid), sequenceNumber(-1) {}
- StoreOperation(
- Target _target,
- Id _slot,
- unsigned _sequenceNumber,
- Id _expression
- ): target(_target), slot(_slot), sequenceNumber(_sequenceNumber), expression(_expression) {}
+
bool isValid() const { return target != Invalid; }
- Target target;
- Id slot;
- unsigned sequenceNumber;
- Id expression;
+
+ Target target{Invalid};
+ Id slot{std::numeric_limits<Id>::max()};
+ unsigned sequenceNumber{std::numeric_limits<unsigned>::max()};
+ Id expression{std::numeric_limits<Id>::max()};
};
explicit KnownState(
diff --git a/liblangutil/CharStream.h b/liblangutil/CharStream.h
index f92beb30..0c998b2a 100644
--- a/liblangutil/CharStream.h
+++ b/liblangutil/CharStream.h
@@ -67,9 +67,9 @@ namespace langutil
class CharStream
{
public:
- CharStream(): m_position(0) {}
+ CharStream() = default;
explicit CharStream(std::string const& _source, std::string const& name):
- m_source(_source), m_name(name), m_position(0) {}
+ m_source(_source), m_name(name) {}
int position() const { return m_position; }
bool isPastEndOfInput(size_t _charsForward = 0) const { return (m_position + _charsForward) >= m_source.size(); }
@@ -94,7 +94,7 @@ public:
private:
std::string m_source;
std::string m_name;
- size_t m_position;
+ size_t m_position{0};
};
}
diff --git a/liblangutil/EVMVersion.h b/liblangutil/EVMVersion.h
index 657727ac..21889bd9 100644
--- a/liblangutil/EVMVersion.h
+++ b/liblangutil/EVMVersion.h
@@ -39,7 +39,7 @@ class EVMVersion:
boost::equality_comparable<EVMVersion>
{
public:
- EVMVersion() {}
+ EVMVersion() = default;
static EVMVersion homestead() { return {Version::Homestead}; }
static EVMVersion tangerineWhistle() { return {Version::TangerineWhistle}; }
diff --git a/liblangutil/SourceReferenceExtractor.h b/liblangutil/SourceReferenceExtractor.h
index 0be7e9d8..bcbc50bc 100644
--- a/liblangutil/SourceReferenceExtractor.h
+++ b/liblangutil/SourceReferenceExtractor.h
@@ -31,28 +31,29 @@ namespace langutil
struct LineColumn
{
- int line;
- int column;
+ int line = {-1};
+ int column = {-1};
+ LineColumn() = default;
LineColumn(std::tuple<int, int> const& _t): line{std::get<0>(_t)}, column{std::get<1>(_t)} {}
- LineColumn(int _line, int _column): line{_line}, column{_column} {}
- LineColumn(): line{-1}, column{-1} {}
};
struct SourceReference
{
- std::string message; ///< A message that relates to this source reference (such as a warning or an error message).
- std::string sourceName; ///< Underlying source name (for example the filename).
- LineColumn position; ///< Actual (error) position this source reference is surrounding.
- bool multiline; ///< Indicates whether the actual SourceReference is truncated to one line.
- std::string text; ///< Extracted source code text (potentially truncated if multiline or too long).
- int startColumn; ///< Highlighting range-start of text field.
- int endColumn; ///< Highlighting range-end of text field.
+ std::string message; ///< A message that relates to this source reference (such as a warning or an error message).
+ std::string sourceName; ///< Underlying source name (for example the filename).
+ LineColumn position; ///< Actual (error) position this source reference is surrounding.
+ bool multiline = {false}; ///< Indicates whether the actual SourceReference is truncated to one line.
+ std::string text; ///< Extracted source code text (potentially truncated if multiline or too long).
+ int startColumn = {-1}; ///< Highlighting range-start of text field.
+ int endColumn = {-1}; ///< Highlighting range-end of text field.
/// Constructs a SourceReference containing a message only.
static SourceReference MessageOnly(std::string _msg)
{
- return SourceReference{std::move(_msg), "", LineColumn{-1, -1}, false, "", -1, -1};
+ SourceReference sref;
+ sref.message = std::move(_msg);
+ return sref;
}
};
diff --git a/liblll/CodeFragment.h b/liblll/CodeFragment.h
index e6e4d3b6..5c2f49a6 100644
--- a/liblll/CodeFragment.h
+++ b/liblll/CodeFragment.h
@@ -41,7 +41,7 @@ class CodeFragment
public:
using ReadCallback = std::function<std::string(std::string const&)>;
- CodeFragment() {}
+ CodeFragment() = default;
CodeFragment(sp::utree const& _t, CompilerState& _s, ReadCallback const& _readFile, bool _allowASM = false);
static CodeFragment compile(std::string const& _src, CompilerState& _s, ReadCallback const& _readFile);
diff --git a/libsolidity/analysis/ControlFlowGraph.h b/libsolidity/analysis/ControlFlowGraph.h
index db8e1565..cc0113d8 100644
--- a/libsolidity/analysis/ControlFlowGraph.h
+++ b/libsolidity/analysis/ControlFlowGraph.h
@@ -103,7 +103,8 @@ struct CFGNode
/** Describes the control flow of a function. */
struct FunctionFlow
{
- virtual ~FunctionFlow() {}
+ virtual ~FunctionFlow() = default;
+
/// Entry node. Control flow of the function starts here.
/// This node is empty and does not have any entries.
CFGNode* entry = nullptr;
diff --git a/libsolidity/ast/ASTAnnotations.h b/libsolidity/ast/ASTAnnotations.h
index 33893a4f..d1acf90b 100644
--- a/libsolidity/ast/ASTAnnotations.h
+++ b/libsolidity/ast/ASTAnnotations.h
@@ -46,7 +46,7 @@ using TypePointer = std::shared_ptr<Type const>;
struct ASTAnnotation
{
- virtual ~ASTAnnotation() {}
+ virtual ~ASTAnnotation() = default;
};
struct DocTag
@@ -57,7 +57,7 @@ struct DocTag
struct DocumentedAnnotation
{
- virtual ~DocumentedAnnotation() {}
+ virtual ~DocumentedAnnotation() = default;
/// Mapping docstring tag name -> content.
std::multimap<std::string, DocTag> docTags;
};
diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h
index ac1487b2..bee00661 100644
--- a/libsolidity/ast/Types.h
+++ b/libsolidity/ast/Types.h
@@ -601,7 +601,6 @@ private:
class BoolType: public Type
{
public:
- BoolType() {}
Category category() const override { return Category::Bool; }
std::string richIdentifier() const override { return "t_bool"; }
TypeResult unaryOperatorResult(Token _operator) const override;
diff --git a/libsolidity/codegen/LValue.h b/libsolidity/codegen/LValue.h
index 3b44597f..3072ff11 100644
--- a/libsolidity/codegen/LValue.h
+++ b/libsolidity/codegen/LValue.h
@@ -49,7 +49,7 @@ protected:
m_context(_compilerContext), m_dataType(_dataType) {}
public:
- virtual ~LValue() {}
+ virtual ~LValue() = default;
/// @returns the number of stack slots occupied by the lvalue reference
virtual unsigned sizeOnStack() const { return 1; }
/// Copies the value of the current lvalue to the top of the stack and, if @a _remove is true,
diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp
index 5b9c309a..8a6bc343 100644
--- a/libsolidity/parsing/Parser.cpp
+++ b/libsolidity/parsing/Parser.cpp
@@ -48,7 +48,7 @@ public:
explicit ASTNodeFactory(Parser const& _parser):
m_parser(_parser), m_location{_parser.position(), -1, _parser.source()} {}
ASTNodeFactory(Parser const& _parser, ASTPointer<ASTNode> const& _childNode):
- m_parser(_parser), m_location(_childNode->location()) {}
+ m_parser(_parser), m_location{_childNode->location()} {}
void markEndPosition() { m_location.end = m_parser.endPosition(); }
void setLocation(SourceLocation const& _location) { m_location = _location; }
diff --git a/libsolidity/parsing/Parser.h b/libsolidity/parsing/Parser.h
index bf02c626..b8d0e9a8 100644
--- a/libsolidity/parsing/Parser.h
+++ b/libsolidity/parsing/Parser.h
@@ -47,7 +47,10 @@ private:
struct VarDeclParserOptions
{
+ // This is actually not needed, but due to a defect in the C++ standard, we have to.
+ // https://stackoverflow.com/questions/17430377
VarDeclParserOptions() {}
+
bool allowVar = false;
bool isStateVariable = false;
bool allowIndexed = false;
@@ -85,7 +88,7 @@ private:
ASTPointer<EnumDefinition> parseEnumDefinition();
ASTPointer<EnumValue> parseEnumValue();
ASTPointer<VariableDeclaration> parseVariableDeclaration(
- VarDeclParserOptions const& _options = VarDeclParserOptions(),
+ VarDeclParserOptions const& _options = {},
ASTPointer<TypeName> const& _lookAheadArrayType = ASTPointer<TypeName>()
);
ASTPointer<ModifierDefinition> parseModifierDefinition();
@@ -99,7 +102,7 @@ private:
ASTPointer<FunctionTypeName> parseFunctionType();
ASTPointer<Mapping> parseMapping();
ASTPointer<ParameterList> parseParameterList(
- VarDeclParserOptions const& _options,
+ VarDeclParserOptions const& _options = {},
bool _allowEmpty = true
);
ASTPointer<Block> parseBlock(ASTPointer<ASTString> const& _docString = {});
diff --git a/libyul/Dialect.h b/libyul/Dialect.h
index 2def566c..01fd98df 100644
--- a/libyul/Dialect.h
+++ b/libyul/Dialect.h
@@ -54,7 +54,7 @@ struct Dialect: boost::noncopyable
virtual BuiltinFunction const* builtin(YulString /*_name*/) const { return nullptr; }
Dialect(AsmFlavour _flavour): flavour(_flavour) {}
- virtual ~Dialect() {}
+ virtual ~Dialect() = default;
static std::shared_ptr<Dialect> yul()
{
diff --git a/libyul/Object.h b/libyul/Object.h
index cfd8d02d..8484eb53 100644
--- a/libyul/Object.h
+++ b/libyul/Object.h
@@ -37,7 +37,7 @@ struct AsmAnalysisInfo;
*/
struct ObjectNode
{
- virtual ~ObjectNode() {}
+ virtual ~ObjectNode() = default;
virtual std::string toString(bool _yul) const = 0;
YulString name;
diff --git a/libyul/YulString.h b/libyul/YulString.h
index 35c1d92d..5cea5619 100644
--- a/libyul/YulString.h
+++ b/libyul/YulString.h
@@ -42,10 +42,9 @@ public:
size_t id;
std::uint64_t hash;
};
- YulStringRepository():
- m_strings{std::make_shared<std::string>()},
- m_hashToID{std::make_pair(emptyHash(), 0)}
- {}
+
+ YulStringRepository() = default;
+
static YulStringRepository& instance()
{
static YulStringRepository inst;
@@ -80,9 +79,10 @@ public:
return hash;
}
static constexpr std::uint64_t emptyHash() { return 14695981039346656037u; }
+
private:
- std::vector<std::shared_ptr<std::string>> m_strings;
- std::unordered_multimap<std::uint64_t, size_t> m_hashToID;
+ std::vector<std::shared_ptr<std::string>> m_strings = {std::make_shared<std::string>()};
+ std::unordered_multimap<std::uint64_t, size_t> m_hashToID = {{emptyHash(), 0}};
};
/// Wrapper around handles into the YulString repository.
diff --git a/libyul/backends/evm/AbstractAssembly.h b/libyul/backends/evm/AbstractAssembly.h
index 1f224ded..0cc41056 100644
--- a/libyul/backends/evm/AbstractAssembly.h
+++ b/libyul/backends/evm/AbstractAssembly.h
@@ -55,7 +55,7 @@ public:
using LabelID = size_t;
using SubID = size_t;
- virtual ~AbstractAssembly() {}
+ virtual ~AbstractAssembly() = default;
/// Set a new source location valid starting from the next instruction.
virtual void setSourceLocation(langutil::SourceLocation const& _location) = 0;
diff --git a/libyul/backends/evm/EVMAssembly.h b/libyul/backends/evm/EVMAssembly.h
index cef9c19a..e62bc87e 100644
--- a/libyul/backends/evm/EVMAssembly.h
+++ b/libyul/backends/evm/EVMAssembly.h
@@ -38,7 +38,7 @@ class EVMAssembly: public AbstractAssembly
{
public:
explicit EVMAssembly(bool _evm15 = false): m_evm15(_evm15) { }
- virtual ~EVMAssembly() {}
+ virtual ~EVMAssembly() = default;
/// Set a new source location valid starting from the next instruction.
void setSourceLocation(langutil::SourceLocation const& _location) override;
diff --git a/libyul/backends/evm/EVMDialect.cpp b/libyul/backends/evm/EVMDialect.cpp
index 33ee19d4..935f05c6 100644
--- a/libyul/backends/evm/EVMDialect.cpp
+++ b/libyul/backends/evm/EVMDialect.cpp
@@ -38,7 +38,7 @@ using namespace dev::solidity;
EVMDialect::EVMDialect(AsmFlavour _flavour, bool _objectAccess):
- Dialect(_flavour), m_objectAccess(_objectAccess)
+ Dialect{_flavour}, m_objectAccess(_objectAccess)
{
// The EVM instructions will be moved to builtins at some point.
if (!m_objectAccess)
diff --git a/libyul/optimiser/RedundantAssignEliminator.h b/libyul/optimiser/RedundantAssignEliminator.h
index 54d65823..4f82e7a2 100644
--- a/libyul/optimiser/RedundantAssignEliminator.h
+++ b/libyul/optimiser/RedundantAssignEliminator.h
@@ -115,7 +115,7 @@ public:
static void run(Block& _ast);
private:
- RedundantAssignEliminator() {}
+ RedundantAssignEliminator() = default;
class State
{
diff --git a/solc/CommandLineInterface.h b/solc/CommandLineInterface.h
index 0b22ca29..ff294adc 100644
--- a/solc/CommandLineInterface.h
+++ b/solc/CommandLineInterface.h
@@ -41,8 +41,6 @@ enum class DocumentationType: uint8_t;
class CommandLineInterface
{
public:
- CommandLineInterface() {}
-
/// Parse command line arguments and return false if we should not continue
bool parseArguments(int _argc, char** _argv);
/// Parse the files and create source code objects
diff --git a/test/TestCase.h b/test/TestCase.h
index 3c05ae4e..27320009 100644
--- a/test/TestCase.h
+++ b/test/TestCase.h
@@ -36,7 +36,7 @@ class TestCase
public:
using TestCaseCreator = std::unique_ptr<TestCase>(*)(std::string const&);
- virtual ~TestCase() {}
+ virtual ~TestCase() = default;
/// Runs the test case.
/// Outputs error messages to @arg _stream. Each line of output is prefixed with @arg _linePrefix.
diff --git a/test/libsolidity/GasMeter.cpp b/test/libsolidity/GasMeter.cpp
index 12c22604..d765d440 100644
--- a/test/libsolidity/GasMeter.cpp
+++ b/test/libsolidity/GasMeter.cpp
@@ -44,7 +44,6 @@ namespace test
class GasMeterTestFramework: public SolidityExecutionFramework
{
public:
- GasMeterTestFramework() { }
void compile(string const& _sourceCode)
{
m_compiler.reset(false);
diff --git a/test/libsolidity/SolidityABIJSON.cpp b/test/libsolidity/SolidityABIJSON.cpp
index a8a67bca..63f2b3a6 100644
--- a/test/libsolidity/SolidityABIJSON.cpp
+++ b/test/libsolidity/SolidityABIJSON.cpp
@@ -38,8 +38,6 @@ namespace test
class JSONInterfaceChecker
{
public:
- JSONInterfaceChecker(): m_compilerStack() {}
-
void checkInterface(std::string const& _code, std::string const& _contractName, std::string const& _expectedInterfaceString)
{
m_compilerStack.reset(false);
diff --git a/test/libsolidity/SolidityNatspecJSON.cpp b/test/libsolidity/SolidityNatspecJSON.cpp
index d930f697..000a7938 100644
--- a/test/libsolidity/SolidityNatspecJSON.cpp
+++ b/test/libsolidity/SolidityNatspecJSON.cpp
@@ -39,8 +39,6 @@ namespace test
class DocumentationChecker
{
public:
- DocumentationChecker(): m_compilerStack() {}
-
void checkNatspec(
std::string const& _code,
std::string const& _contractName,
diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp
index f925d36e..b5ce6f2a 100644
--- a/test/libsolidity/SolidityOptimizer.cpp
+++ b/test/libsolidity/SolidityOptimizer.cpp
@@ -45,8 +45,6 @@ namespace test
class OptimizerTestFramework: public SolidityExecutionFramework
{
public:
- OptimizerTestFramework() { }
-
bytes const& compileAndRunWithOptimizer(
std::string const& _sourceCode,
u256 const& _value = 0,