Skip to content

Commit e6f7d5a

Browse files
authored
Merge pull request #8095 from ethereum/develop
Merge develop into release for 0.6.1
2 parents 26b7007 + 1cc7eb7 commit e6f7d5a

File tree

92 files changed

+817
-317
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+817
-317
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ include(EthPolicy)
1010
eth_policy()
1111

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

1616
include(TestBigEndian)

Changelog.md

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
### 0.6.1 (2020-01-02)
2+
3+
Bugfixes:
4+
* Yul Optimizer: Fix bug in redundant assignment remover in combination with break and continue statements.
5+
6+
17
### 0.6.0 (2019-12-17)
28

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

4754

55+
### 0.5.16 (2020-01-02)
56+
57+
Backported Bugfixes:
58+
* Yul Optimizer: Fix bug in redundant assignment remover in combination with break and continue statements.
59+
60+
4861
### 0.5.15 (2019-12-17)
4962

5063
Bugfixes:

docs/bugs.json

+22
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
11
[
2+
{
3+
"name": "YulOptimizerRedundantAssignmentBreakContinue",
4+
"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.",
5+
"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.",
6+
"introduced": "0.6.0",
7+
"fixed": "0.6.1",
8+
"severity": "medium",
9+
"conditions": {
10+
"yulOptimizer": true
11+
}
12+
},
13+
{
14+
"name": "YulOptimizerRedundantAssignmentBreakContinue0.5",
15+
"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.",
16+
"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.",
17+
"introduced": "0.5.8",
18+
"fixed": "0.5.16",
19+
"severity": "low",
20+
"conditions": {
21+
"yulOptimizer": true
22+
}
23+
},
224
{
325
"name": "ABIEncoderV2LoopYulOptimizer",
426
"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.",

docs/bugs_by_version.json

+27-5
Original file line numberDiff line numberDiff line change
@@ -742,32 +742,46 @@
742742
},
743743
"0.5.10": {
744744
"bugs": [
745+
"YulOptimizerRedundantAssignmentBreakContinue0.5",
745746
"ABIEncoderV2CalldataStructsWithStaticallySizedAndDynamicallyEncodedMembers"
746747
],
747748
"released": "2019-06-25"
748749
},
749750
"0.5.11": {
750-
"bugs": [],
751+
"bugs": [
752+
"YulOptimizerRedundantAssignmentBreakContinue0.5"
753+
],
751754
"released": "2019-08-12"
752755
},
753756
"0.5.12": {
754-
"bugs": [],
757+
"bugs": [
758+
"YulOptimizerRedundantAssignmentBreakContinue0.5"
759+
],
755760
"released": "2019-10-01"
756761
},
757762
"0.5.13": {
758-
"bugs": [],
763+
"bugs": [
764+
"YulOptimizerRedundantAssignmentBreakContinue0.5"
765+
],
759766
"released": "2019-11-14"
760767
},
761768
"0.5.14": {
762769
"bugs": [
770+
"YulOptimizerRedundantAssignmentBreakContinue0.5",
763771
"ABIEncoderV2LoopYulOptimizer"
764772
],
765773
"released": "2019-12-09"
766774
},
767775
"0.5.15": {
768-
"bugs": [],
776+
"bugs": [
777+
"YulOptimizerRedundantAssignmentBreakContinue0.5"
778+
],
769779
"released": "2019-12-17"
770780
},
781+
"0.5.16": {
782+
"bugs": [],
783+
"released": "2020-01-02"
784+
},
771785
"0.5.2": {
772786
"bugs": [
773787
"SignedArrayStorageCopy",
@@ -840,6 +854,7 @@
840854
},
841855
"0.5.8": {
842856
"bugs": [
857+
"YulOptimizerRedundantAssignmentBreakContinue0.5",
843858
"ABIEncoderV2CalldataStructsWithStaticallySizedAndDynamicallyEncodedMembers",
844859
"SignedArrayStorageCopy",
845860
"ABIEncoderV2StorageArrayWithMultiSlotElement",
@@ -849,14 +864,21 @@
849864
},
850865
"0.5.9": {
851866
"bugs": [
867+
"YulOptimizerRedundantAssignmentBreakContinue0.5",
852868
"ABIEncoderV2CalldataStructsWithStaticallySizedAndDynamicallyEncodedMembers",
853869
"SignedArrayStorageCopy",
854870
"ABIEncoderV2StorageArrayWithMultiSlotElement"
855871
],
856872
"released": "2019-05-28"
857873
},
858874
"0.6.0": {
859-
"bugs": [],
875+
"bugs": [
876+
"YulOptimizerRedundantAssignmentBreakContinue"
877+
],
860878
"released": "2019-12-17"
879+
},
880+
"0.6.1": {
881+
"bugs": [],
882+
"released": "2020-01-02"
861883
}
862884
}

docs/resources.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Solidity Integrations
3333
* `Solidity IDE <https://github.com/System-Glitch/Solidity-IDE>`_
3434
Browser-based IDE with integrated compiler, Ganache and local file system support.
3535

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

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

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

5353
* Eclipse:
5454

libsolidity/analysis/NameAndTypeResolver.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ void DeclarationRegistrationHelper::endVisit(FunctionDefinition&)
639639

640640
bool DeclarationRegistrationHelper::visit(TryCatchClause& _tryCatchClause)
641641
{
642-
_tryCatchClause.setScope(m_currentScope);
642+
_tryCatchClause.annotation().scope = m_currentScope;
643643
enterNewSubScope(_tryCatchClause);
644644
return true;
645645
}
@@ -675,7 +675,7 @@ void DeclarationRegistrationHelper::endVisit(FunctionTypeName&)
675675

676676
bool DeclarationRegistrationHelper::visit(Block& _block)
677677
{
678-
_block.setScope(m_currentScope);
678+
_block.annotation().scope = m_currentScope;
679679
enterNewSubScope(_block);
680680
return true;
681681
}
@@ -687,7 +687,7 @@ void DeclarationRegistrationHelper::endVisit(Block&)
687687

688688
bool DeclarationRegistrationHelper::visit(ForStatement& _for)
689689
{
690-
_for.setScope(m_currentScope);
690+
_for.annotation().scope = m_currentScope;
691691
enterNewSubScope(_for);
692692
return true;
693693
}
@@ -761,7 +761,7 @@ void DeclarationRegistrationHelper::registerDeclaration(Declaration& _declaratio
761761

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

764-
_declaration.setScope(m_currentScope);
764+
_declaration.annotation().scope = m_currentScope;
765765
if (_opensScope)
766766
enterNewSubScope(_declaration);
767767
}

libsolidity/analysis/ViewPureChecker.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ class AssemblyViewPureChecker
4343
m_dialect(_dialect),
4444
m_reportMutability(_reportMutability) {}
4545

46-
void operator()(yul::Instruction const& _instruction)
47-
{
48-
checkInstruction(_instruction.location, _instruction.instruction);
49-
}
5046
void operator()(yul::Literal const&) {}
5147
void operator()(yul::Identifier const&) {}
5248
void operator()(yul::ExpressionStatement const& _expr)

libsolidity/ast/AST.cpp

+28
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,13 @@ string Scopable::sourceUnitName() const
449449
return sourceUnit().annotation().path;
450450
}
451451

452+
DeclarationAnnotation& Declaration::annotation() const
453+
{
454+
if (!m_annotation)
455+
m_annotation = make_unique<DeclarationAnnotation>();
456+
return dynamic_cast<DeclarationAnnotation&>(*m_annotation);
457+
}
458+
452459
bool VariableDeclaration::isLValue() const
453460
{
454461
// Constant declared variables are Read-Only
@@ -653,6 +660,27 @@ InlineAssemblyAnnotation& InlineAssembly::annotation() const
653660
return dynamic_cast<InlineAssemblyAnnotation&>(*m_annotation);
654661
}
655662

663+
BlockAnnotation& Block::annotation() const
664+
{
665+
if (!m_annotation)
666+
m_annotation = make_unique<BlockAnnotation>();
667+
return dynamic_cast<BlockAnnotation&>(*m_annotation);
668+
}
669+
670+
TryCatchClauseAnnotation& TryCatchClause::annotation() const
671+
{
672+
if (!m_annotation)
673+
m_annotation = make_unique<TryCatchClauseAnnotation>();
674+
return dynamic_cast<TryCatchClauseAnnotation&>(*m_annotation);
675+
}
676+
677+
ForStatementAnnotation& ForStatement::annotation() const
678+
{
679+
if (!m_annotation)
680+
m_annotation = make_unique<ForStatementAnnotation>();
681+
return dynamic_cast<ForStatementAnnotation&>(*m_annotation);
682+
}
683+
656684
ReturnAnnotation& Return::annotation() const
657685
{
658686
if (!m_annotation)

libsolidity/ast/AST.h

+10-4
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,7 @@ class Scopable
159159
virtual ~Scopable() = default;
160160
/// @returns the scope this declaration resides in. Can be nullptr if it is the global scope.
161161
/// Available only after name and type resolution step.
162-
ASTNode const* scope() const { return m_scope; }
163-
void setScope(ASTNode const* _scope) { m_scope = _scope; }
162+
ASTNode const* scope() const { return annotation().scope; }
164163

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

175-
protected:
176-
ASTNode const* m_scope = nullptr;
174+
virtual ScopableAnnotation& annotation() const = 0;
177175
};
178176

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

232+
DeclarationAnnotation& annotation() const override;
233+
234234
protected:
235235
virtual Visibility defaultVisibility() const { return Visibility::Public; }
236236

@@ -1169,6 +1169,8 @@ class Block: public Statement, public Scopable
11691169

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

1172+
BlockAnnotation& annotation() const override;
1173+
11721174
private:
11731175
std::vector<ASTPointer<Statement>> m_statements;
11741176
};
@@ -1248,6 +1250,8 @@ class TryCatchClause: public ASTNode, public Scopable
12481250
ParameterList const* parameters() const { return m_parameters.get(); }
12491251
Block const& block() const { return *m_block; }
12501252

1253+
TryCatchClauseAnnotation& annotation() const override;
1254+
12511255
private:
12521256
ASTPointer<ASTString> m_errorName;
12531257
ASTPointer<ParameterList> m_parameters;
@@ -1357,6 +1361,8 @@ class ForStatement: public BreakableStatement, public Scopable
13571361
ExpressionStatement const* loopExpression() const { return m_loopExpression.get(); }
13581362
Statement const& body() const { return *m_body; }
13591363

1364+
ForStatementAnnotation& annotation() const override;
1365+
13601366
private:
13611367
/// For statement's initialization expression. for (XXX; ; ). Can be empty
13621368
ASTPointer<Statement> m_initExpression;

libsolidity/ast/ASTAnnotations.h

+27-4
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,26 @@ struct SourceUnitAnnotation: ASTAnnotation
7575
std::set<ExperimentalFeature> experimentalFeatures;
7676
};
7777

78-
struct ImportAnnotation: ASTAnnotation
78+
struct ScopableAnnotation
79+
{
80+
/// The scope this declaration resides in. Can be nullptr if it is the global scope.
81+
/// Available only after name and type resolution step.
82+
ASTNode const* scope = nullptr;
83+
};
84+
85+
struct DeclarationAnnotation: ASTAnnotation, ScopableAnnotation
86+
{
87+
};
88+
89+
struct ImportAnnotation: DeclarationAnnotation
7990
{
8091
/// The absolute path of the source unit to import.
8192
std::string absolutePath;
8293
/// The actual source unit.
8394
SourceUnit const* sourceUnit = nullptr;
8495
};
8596

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

107-
struct CallableDeclarationAnnotation: ASTAnnotation
118+
struct CallableDeclarationAnnotation: DeclarationAnnotation
108119
{
109120
/// The set of functions/modifiers/events this callable overrides.
110121
std::set<CallableDeclaration const*> baseFunctions;
@@ -124,7 +135,7 @@ struct ModifierDefinitionAnnotation: CallableDeclarationAnnotation, DocumentedAn
124135
{
125136
};
126137

127-
struct VariableDeclarationAnnotation: ASTAnnotation
138+
struct VariableDeclarationAnnotation: DeclarationAnnotation
128139
{
129140
/// Type of variable (type of identifier referencing this variable).
130141
TypePointer type = nullptr;
@@ -152,6 +163,18 @@ struct InlineAssemblyAnnotation: StatementAnnotation
152163
std::shared_ptr<yul::AsmAnalysisInfo> analysisInfo;
153164
};
154165

166+
struct BlockAnnotation: StatementAnnotation, ScopableAnnotation
167+
{
168+
};
169+
170+
struct TryCatchClauseAnnotation: ASTAnnotation, ScopableAnnotation
171+
{
172+
};
173+
174+
struct ForStatementAnnotation: StatementAnnotation, ScopableAnnotation
175+
{
176+
};
177+
155178
struct ReturnAnnotation: StatementAnnotation
156179
{
157180
/// Reference to the return parameters of the function.

0 commit comments

Comments
 (0)