Skip to content

Commit

Permalink
Merge pull request #8095 from ethereum/develop
Browse files Browse the repository at this point in the history
Merge develop into release for 0.6.1
  • Loading branch information
chriseth authored Jan 2, 2020
2 parents 26b7007 + 1cc7eb7 commit e6f7d5a
Show file tree
Hide file tree
Showing 92 changed files with 817 additions and 317 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ include(EthPolicy)
eth_policy()

# project name and version should be set after cmake_policy CMP0048
set(PROJECT_VERSION "0.6.0")
set(PROJECT_VERSION "0.6.1")
project(solidity VERSION ${PROJECT_VERSION} LANGUAGES C CXX)

include(TestBigEndian)
Expand Down
13 changes: 13 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### 0.6.1 (2020-01-02)

Bugfixes:
* Yul Optimizer: Fix bug in redundant assignment remover in combination with break and continue statements.


### 0.6.0 (2019-12-17)

Breaking changes:
Expand Down Expand Up @@ -33,6 +39,7 @@ Language Features:
* Allow global enums and structs.
* Allow public variables to override external functions.
* Allow underscores as delimiters in hex strings.
* Allow to react on failing external calls using ``try`` and ``catch``.
* Introduce syntax for array slices and implement them for dynamic calldata arrays.
* Introduce ``push()`` for dynamic storage arrays. It returns a reference to the newly allocated element, if applicable.
* Introduce ``virtual`` and ``override`` keywords.
Expand All @@ -45,6 +52,12 @@ Compiler Features:
* ABIEncoderV2: Do not warn about enabled ABIEncoderV2 anymore (the pragma is still needed, though).


### 0.5.16 (2020-01-02)

Backported Bugfixes:
* Yul Optimizer: Fix bug in redundant assignment remover in combination with break and continue statements.


### 0.5.15 (2019-12-17)

Bugfixes:
Expand Down
22 changes: 22 additions & 0 deletions docs/bugs.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
[
{
"name": "YulOptimizerRedundantAssignmentBreakContinue",
"summary": "The Yul optimizer can remove essential assignments to variables declared inside for loops when Yul's continue or break statement is used. You are unlikely to be affected if you do not use inline assembly with for loops and continue and break statements.",
"description": "The Yul optimizer has a stage that removes assignments to variables that are overwritten again or are not used in all following control-flow branches. This logic incorrectly removes such assignments to variables declared inside a for loop if they can be removed in a control-flow branch that ends with ``break`` or ``continue`` even though they cannot be removed in other control-flow branches. Variables declared outside of the respective for loop are not affected.",
"introduced": "0.6.0",
"fixed": "0.6.1",
"severity": "medium",
"conditions": {
"yulOptimizer": true
}
},
{
"name": "YulOptimizerRedundantAssignmentBreakContinue0.5",
"summary": "The Yul optimizer can remove essential assignments to variables declared inside for loops when Yul's continue or break statement is used. You are unlikely to be affected if you do not use inline assembly with for loops and continue and break statements.",
"description": "The Yul optimizer has a stage that removes assignments to variables that are overwritten again or are not used in all following control-flow branches. This logic incorrectly removes such assignments to variables declared inside a for loop if they can be removed in a control-flow branch that ends with ``break`` or ``continue`` even though they cannot be removed in other control-flow branches. Variables declared outside of the respective for loop are not affected.",
"introduced": "0.5.8",
"fixed": "0.5.16",
"severity": "low",
"conditions": {
"yulOptimizer": true
}
},
{
"name": "ABIEncoderV2LoopYulOptimizer",
"summary": "If both the experimental ABIEncoderV2 and the experimental Yul optimizer are activated, one component of the Yul optimizer may reuse data in memory that has been changed in the meantime.",
Expand Down
32 changes: 27 additions & 5 deletions docs/bugs_by_version.json
Original file line number Diff line number Diff line change
Expand Up @@ -742,32 +742,46 @@
},
"0.5.10": {
"bugs": [
"YulOptimizerRedundantAssignmentBreakContinue0.5",
"ABIEncoderV2CalldataStructsWithStaticallySizedAndDynamicallyEncodedMembers"
],
"released": "2019-06-25"
},
"0.5.11": {
"bugs": [],
"bugs": [
"YulOptimizerRedundantAssignmentBreakContinue0.5"
],
"released": "2019-08-12"
},
"0.5.12": {
"bugs": [],
"bugs": [
"YulOptimizerRedundantAssignmentBreakContinue0.5"
],
"released": "2019-10-01"
},
"0.5.13": {
"bugs": [],
"bugs": [
"YulOptimizerRedundantAssignmentBreakContinue0.5"
],
"released": "2019-11-14"
},
"0.5.14": {
"bugs": [
"YulOptimizerRedundantAssignmentBreakContinue0.5",
"ABIEncoderV2LoopYulOptimizer"
],
"released": "2019-12-09"
},
"0.5.15": {
"bugs": [],
"bugs": [
"YulOptimizerRedundantAssignmentBreakContinue0.5"
],
"released": "2019-12-17"
},
"0.5.16": {
"bugs": [],
"released": "2020-01-02"
},
"0.5.2": {
"bugs": [
"SignedArrayStorageCopy",
Expand Down Expand Up @@ -840,6 +854,7 @@
},
"0.5.8": {
"bugs": [
"YulOptimizerRedundantAssignmentBreakContinue0.5",
"ABIEncoderV2CalldataStructsWithStaticallySizedAndDynamicallyEncodedMembers",
"SignedArrayStorageCopy",
"ABIEncoderV2StorageArrayWithMultiSlotElement",
Expand All @@ -849,14 +864,21 @@
},
"0.5.9": {
"bugs": [
"YulOptimizerRedundantAssignmentBreakContinue0.5",
"ABIEncoderV2CalldataStructsWithStaticallySizedAndDynamicallyEncodedMembers",
"SignedArrayStorageCopy",
"ABIEncoderV2StorageArrayWithMultiSlotElement"
],
"released": "2019-05-28"
},
"0.6.0": {
"bugs": [],
"bugs": [
"YulOptimizerRedundantAssignmentBreakContinue"
],
"released": "2019-12-17"
},
"0.6.1": {
"bugs": [],
"released": "2020-01-02"
}
}
4 changes: 2 additions & 2 deletions docs/resources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Solidity Integrations
* `Solidity IDE <https://github.com/System-Glitch/Solidity-IDE>`_
Browser-based IDE with integrated compiler, Ganache and local file system support.

* `Solium <https://github.com/duaraghav8/Solium/>`_
* `Ethlint <https://github.com/duaraghav8/Ethlint>`_
Linter to identify and fix style and security issues in Solidity.

* `Superblocks Lab <https://lab.superblocks.com/>`_
Expand All @@ -48,7 +48,7 @@ Solidity Integrations
Plugin for the Atom editor that provides Solidity linting.

* `Atom Solium Linter <https://atom.io/packages/linter-solium>`_
Configurable Solidty linter for Atom using Solium as a base.
Configurable Solidity linter for Atom using Solium (now Ethlint) as a base.

* Eclipse:

Expand Down
8 changes: 4 additions & 4 deletions libsolidity/analysis/NameAndTypeResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ void DeclarationRegistrationHelper::endVisit(FunctionDefinition&)

bool DeclarationRegistrationHelper::visit(TryCatchClause& _tryCatchClause)
{
_tryCatchClause.setScope(m_currentScope);
_tryCatchClause.annotation().scope = m_currentScope;
enterNewSubScope(_tryCatchClause);
return true;
}
Expand Down Expand Up @@ -675,7 +675,7 @@ void DeclarationRegistrationHelper::endVisit(FunctionTypeName&)

bool DeclarationRegistrationHelper::visit(Block& _block)
{
_block.setScope(m_currentScope);
_block.annotation().scope = m_currentScope;
enterNewSubScope(_block);
return true;
}
Expand All @@ -687,7 +687,7 @@ void DeclarationRegistrationHelper::endVisit(Block&)

bool DeclarationRegistrationHelper::visit(ForStatement& _for)
{
_for.setScope(m_currentScope);
_for.annotation().scope = m_currentScope;
enterNewSubScope(_for);
return true;
}
Expand Down Expand Up @@ -761,7 +761,7 @@ void DeclarationRegistrationHelper::registerDeclaration(Declaration& _declaratio

registerDeclaration(*m_scopes[m_currentScope], _declaration, nullptr, nullptr, warnAboutShadowing, inactive, m_errorReporter);

_declaration.setScope(m_currentScope);
_declaration.annotation().scope = m_currentScope;
if (_opensScope)
enterNewSubScope(_declaration);
}
Expand Down
4 changes: 0 additions & 4 deletions libsolidity/analysis/ViewPureChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ class AssemblyViewPureChecker
m_dialect(_dialect),
m_reportMutability(_reportMutability) {}

void operator()(yul::Instruction const& _instruction)
{
checkInstruction(_instruction.location, _instruction.instruction);
}
void operator()(yul::Literal const&) {}
void operator()(yul::Identifier const&) {}
void operator()(yul::ExpressionStatement const& _expr)
Expand Down
28 changes: 28 additions & 0 deletions libsolidity/ast/AST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,13 @@ string Scopable::sourceUnitName() const
return sourceUnit().annotation().path;
}

DeclarationAnnotation& Declaration::annotation() const
{
if (!m_annotation)
m_annotation = make_unique<DeclarationAnnotation>();
return dynamic_cast<DeclarationAnnotation&>(*m_annotation);
}

bool VariableDeclaration::isLValue() const
{
// Constant declared variables are Read-Only
Expand Down Expand Up @@ -653,6 +660,27 @@ InlineAssemblyAnnotation& InlineAssembly::annotation() const
return dynamic_cast<InlineAssemblyAnnotation&>(*m_annotation);
}

BlockAnnotation& Block::annotation() const
{
if (!m_annotation)
m_annotation = make_unique<BlockAnnotation>();
return dynamic_cast<BlockAnnotation&>(*m_annotation);
}

TryCatchClauseAnnotation& TryCatchClause::annotation() const
{
if (!m_annotation)
m_annotation = make_unique<TryCatchClauseAnnotation>();
return dynamic_cast<TryCatchClauseAnnotation&>(*m_annotation);
}

ForStatementAnnotation& ForStatement::annotation() const
{
if (!m_annotation)
m_annotation = make_unique<ForStatementAnnotation>();
return dynamic_cast<ForStatementAnnotation&>(*m_annotation);
}

ReturnAnnotation& Return::annotation() const
{
if (!m_annotation)
Expand Down
14 changes: 10 additions & 4 deletions libsolidity/ast/AST.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ class Scopable
virtual ~Scopable() = default;
/// @returns the scope this declaration resides in. Can be nullptr if it is the global scope.
/// Available only after name and type resolution step.
ASTNode const* scope() const { return m_scope; }
void setScope(ASTNode const* _scope) { m_scope = _scope; }
ASTNode const* scope() const { return annotation().scope; }

/// @returns the source unit this scopable is present in.
SourceUnit const& sourceUnit() const;
Expand All @@ -172,8 +171,7 @@ class Scopable
/// Can be combined with annotation().canonicalName (if present) to form a globally unique name.
std::string sourceUnitName() const;

protected:
ASTNode const* m_scope = nullptr;
virtual ScopableAnnotation& annotation() const = 0;
};

/**
Expand Down Expand Up @@ -231,6 +229,8 @@ class Declaration: public ASTNode, public Scopable
/// @returns null when it is not accessible as a function.
virtual FunctionTypePointer functionType(bool /*_internal*/) const { return {}; }

DeclarationAnnotation& annotation() const override;

protected:
virtual Visibility defaultVisibility() const { return Visibility::Public; }

Expand Down Expand Up @@ -1169,6 +1169,8 @@ class Block: public Statement, public Scopable

std::vector<ASTPointer<Statement>> const& statements() const { return m_statements; }

BlockAnnotation& annotation() const override;

private:
std::vector<ASTPointer<Statement>> m_statements;
};
Expand Down Expand Up @@ -1248,6 +1250,8 @@ class TryCatchClause: public ASTNode, public Scopable
ParameterList const* parameters() const { return m_parameters.get(); }
Block const& block() const { return *m_block; }

TryCatchClauseAnnotation& annotation() const override;

private:
ASTPointer<ASTString> m_errorName;
ASTPointer<ParameterList> m_parameters;
Expand Down Expand Up @@ -1357,6 +1361,8 @@ class ForStatement: public BreakableStatement, public Scopable
ExpressionStatement const* loopExpression() const { return m_loopExpression.get(); }
Statement const& body() const { return *m_body; }

ForStatementAnnotation& annotation() const override;

private:
/// For statement's initialization expression. for (XXX; ; ). Can be empty
ASTPointer<Statement> m_initExpression;
Expand Down
31 changes: 27 additions & 4 deletions libsolidity/ast/ASTAnnotations.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,26 @@ struct SourceUnitAnnotation: ASTAnnotation
std::set<ExperimentalFeature> experimentalFeatures;
};

struct ImportAnnotation: ASTAnnotation
struct ScopableAnnotation
{
/// The scope this declaration resides in. Can be nullptr if it is the global scope.
/// Available only after name and type resolution step.
ASTNode const* scope = nullptr;
};

struct DeclarationAnnotation: ASTAnnotation, ScopableAnnotation
{
};

struct ImportAnnotation: DeclarationAnnotation
{
/// The absolute path of the source unit to import.
std::string absolutePath;
/// The actual source unit.
SourceUnit const* sourceUnit = nullptr;
};

struct TypeDeclarationAnnotation: ASTAnnotation
struct TypeDeclarationAnnotation: DeclarationAnnotation
{
/// The name of this type, prefixed by proper namespaces if globally accessible.
std::string canonicalName;
Expand All @@ -104,7 +115,7 @@ struct ContractDefinitionAnnotation: TypeDeclarationAnnotation, DocumentedAnnota
std::map<FunctionDefinition const*, ASTNode const*> baseConstructorArguments;
};

struct CallableDeclarationAnnotation: ASTAnnotation
struct CallableDeclarationAnnotation: DeclarationAnnotation
{
/// The set of functions/modifiers/events this callable overrides.
std::set<CallableDeclaration const*> baseFunctions;
Expand All @@ -124,7 +135,7 @@ struct ModifierDefinitionAnnotation: CallableDeclarationAnnotation, DocumentedAn
{
};

struct VariableDeclarationAnnotation: ASTAnnotation
struct VariableDeclarationAnnotation: DeclarationAnnotation
{
/// Type of variable (type of identifier referencing this variable).
TypePointer type = nullptr;
Expand Down Expand Up @@ -152,6 +163,18 @@ struct InlineAssemblyAnnotation: StatementAnnotation
std::shared_ptr<yul::AsmAnalysisInfo> analysisInfo;
};

struct BlockAnnotation: StatementAnnotation, ScopableAnnotation
{
};

struct TryCatchClauseAnnotation: ASTAnnotation, ScopableAnnotation
{
};

struct ForStatementAnnotation: StatementAnnotation, ScopableAnnotation
{
};

struct ReturnAnnotation: StatementAnnotation
{
/// Reference to the return parameters of the function.
Expand Down
Loading

0 comments on commit e6f7d5a

Please sign in to comment.