-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revert statement. #11037
Merged
Merged
Revert statement. #11037
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fb67051
Revert statement.
chriseth b552e5a
AST import and export for revert statement.
chriseth 3353107
Grammar for revert statement.
chriseth d566969
Code generation for errors.
chriseth 1057fd5
Take revert statement into account in control flow graph.
chriseth e877e2b
Use all referenced errors.
chriseth d80059f
Skip certain test for grammar test.
chriseth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
This file is part of solidity. | ||
|
||
solidity is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
solidity is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
|
||
You should have received a copy of the GNU General Public License | ||
along with solidity. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
/** | ||
* Component that verifies overloads, abstract contracts, function clashes and others | ||
* checks at contract or function level. | ||
*/ | ||
|
||
#include <libsolidity/analysis/PostTypeContractLevelChecker.h> | ||
|
||
#include <libsolidity/ast/AST.h> | ||
#include <libsolutil/FunctionSelector.h> | ||
#include <liblangutil/ErrorReporter.h> | ||
|
||
using namespace std; | ||
using namespace solidity; | ||
using namespace solidity::langutil; | ||
using namespace solidity::frontend; | ||
|
||
bool PostTypeContractLevelChecker::check(SourceUnit const& _sourceUnit) | ||
{ | ||
bool noErrors = true; | ||
for (auto* contract: ASTNode::filteredNodes<ContractDefinition>(_sourceUnit.nodes())) | ||
if (!check(*contract)) | ||
noErrors = false; | ||
return noErrors; | ||
} | ||
|
||
bool PostTypeContractLevelChecker::check(ContractDefinition const& _contract) | ||
{ | ||
solAssert( | ||
_contract.annotation().creationCallGraph.set() && | ||
_contract.annotation().deployedCallGraph.set(), | ||
"" | ||
); | ||
|
||
map<uint32_t, map<string, SourceLocation>> errorHashes; | ||
for (ErrorDefinition const* error: _contract.interfaceErrors()) | ||
{ | ||
string signature = error->functionType(true)->externalSignature(); | ||
uint32_t hash = selectorFromSignature32(signature); | ||
// Fail if there is a different signature for the same hash. | ||
if (!errorHashes[hash].empty() && !errorHashes[hash].count(signature)) | ||
cameel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
SourceLocation& otherLocation = errorHashes[hash].begin()->second; | ||
m_errorReporter.typeError( | ||
4883_error, | ||
error->nameLocation(), | ||
SecondarySourceLocation{}.append("This error has a different signature but the same hash: ", otherLocation), | ||
"Error signature hash collision for " + error->functionType(true)->externalSignature() | ||
); | ||
} | ||
else | ||
errorHashes[hash][signature] = error->location(); | ||
} | ||
|
||
return Error::containsOnlyWarnings(m_errorReporter.errors()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
This file is part of solidity. | ||
|
||
solidity is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
solidity is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
|
||
You should have received a copy of the GNU General Public License | ||
along with solidity. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
/** | ||
* Component that verifies properties at contract level, after the type checker has run. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <libsolidity/ast/ASTForward.h> | ||
|
||
namespace solidity::langutil | ||
{ | ||
class ErrorReporter; | ||
} | ||
|
||
namespace solidity::frontend | ||
{ | ||
|
||
/** | ||
* Component that verifies properties at contract level, after the type checker has run. | ||
*/ | ||
class PostTypeContractLevelChecker | ||
{ | ||
public: | ||
explicit PostTypeContractLevelChecker(langutil::ErrorReporter& _errorReporter): | ||
m_errorReporter(_errorReporter) | ||
{} | ||
|
||
/// Performs checks on the given source ast. | ||
/// @returns true iff all checks passed. Note even if all checks passed, errors() can still contain warnings | ||
bool check(SourceUnit const& _sourceUnit); | ||
|
||
private: | ||
/// Performs checks on the given contract. | ||
/// @returns true iff all checks passed. Note even if all checks passed, errors() can still contain warnings | ||
bool check(ContractDefinition const& _contract); | ||
|
||
langutil::ErrorReporter& m_errorReporter; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should add an assert here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean as
else
? Not really. There are other case possible here, the graph just skips them.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a check and I would say it is highly unlikely for this assert to trigger...