-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Store both Yul and Solidity locations in debug data #11998
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
Changes from all commits
84ca67c
9c1d40d
ce4420f
d23754e
fc7e8c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -201,9 +201,13 @@ bool ReferencesResolver::visit(Return const& _return) | |
|
|
||
| void ReferencesResolver::operator()(yul::FunctionDefinition const& _function) | ||
| { | ||
| validateYulIdentifierName(_function.name, _function.debugData->location); | ||
| solAssert(nativeLocationOf(_function) == originLocationOf(_function), ""); | ||
| validateYulIdentifierName(_function.name, nativeLocationOf(_function)); | ||
| for (yul::TypedName const& varName: _function.parameters + _function.returnVariables) | ||
| validateYulIdentifierName(varName.name, varName.debugData->location); | ||
| { | ||
| solAssert(nativeLocationOf(varName) == originLocationOf(varName), ""); | ||
| validateYulIdentifierName(varName.name, nativeLocationOf(varName)); | ||
| } | ||
|
|
||
| bool wasInsideFunction = m_yulInsideFunction; | ||
| m_yulInsideFunction = true; | ||
|
|
@@ -213,6 +217,8 @@ void ReferencesResolver::operator()(yul::FunctionDefinition const& _function) | |
|
|
||
| void ReferencesResolver::operator()(yul::Identifier const& _identifier) | ||
| { | ||
| solAssert(nativeLocationOf(_identifier) == originLocationOf(_identifier), ""); | ||
|
|
||
| static set<string> suffixes{"slot", "offset", "length"}; | ||
| string suffix; | ||
| for (string const& s: suffixes) | ||
|
|
@@ -238,7 +244,7 @@ void ReferencesResolver::operator()(yul::Identifier const& _identifier) | |
| { | ||
| m_errorReporter.declarationError( | ||
| 4718_error, | ||
| _identifier.debugData->location, | ||
| nativeLocationOf(_identifier), | ||
| "Multiple matching identifiers. Resolving overloaded identifiers is not supported." | ||
| ); | ||
|
Comment on lines
245
to
249
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The assertion I added for this is actually failing during AST export and reimport of contract C {
uint[] x;
fallback() external {
uint y_slot = 2;
uint y_offset = 3;
uint[] storage y = x;
assembly {
pop(y_slot)
pop(y_offset)
}
y[0] = 2;
}
}
// ----This is why CLI tests are failing. BTW the error handling for AST import is swallowing errors at multiple levels (both in solc and in the test script), which makes it harder to debug than it should be. |
||
| return; | ||
|
|
@@ -251,7 +257,7 @@ void ReferencesResolver::operator()(yul::Identifier const& _identifier) | |
| ) | ||
| m_errorReporter.declarationError( | ||
| 9467_error, | ||
| _identifier.debugData->location, | ||
| nativeLocationOf(_identifier), | ||
| "Identifier not found. Use \".slot\" and \".offset\" to access storage variables." | ||
| ); | ||
| return; | ||
|
|
@@ -261,7 +267,7 @@ void ReferencesResolver::operator()(yul::Identifier const& _identifier) | |
| { | ||
| m_errorReporter.declarationError( | ||
| 6578_error, | ||
| _identifier.debugData->location, | ||
| nativeLocationOf(_identifier), | ||
| "Cannot access local Solidity variables from inside an inline assembly function." | ||
| ); | ||
| return; | ||
|
|
@@ -275,8 +281,8 @@ void ReferencesResolver::operator()(yul::VariableDeclaration const& _varDecl) | |
| { | ||
| for (auto const& identifier: _varDecl.variables) | ||
| { | ||
| validateYulIdentifierName(identifier.name, identifier.debugData->location); | ||
|
|
||
| solAssert(nativeLocationOf(identifier) == originLocationOf(identifier), ""); | ||
| validateYulIdentifierName(identifier.name, nativeLocationOf(identifier)); | ||
|
|
||
| if ( | ||
| auto declarations = m_resolver.nameFromCurrentScope(identifier.name.str()); | ||
|
|
@@ -289,7 +295,7 @@ void ReferencesResolver::operator()(yul::VariableDeclaration const& _varDecl) | |
| if (!ssl.infos.empty()) | ||
| m_errorReporter.declarationError( | ||
| 3859_error, | ||
| identifier.debugData->location, | ||
| nativeLocationOf(identifier), | ||
| ssl, | ||
| "This declaration shadows a declaration outside the inline assembly block." | ||
| ); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -171,10 +171,10 @@ void ASTJsonConverter::appendExpressionAttributes( | |
| _attributes += exprAttributes; | ||
| } | ||
|
|
||
| Json::Value ASTJsonConverter::inlineAssemblyIdentifierToJson(pair<yul::Identifier const* ,InlineAssemblyAnnotation::ExternalIdentifierInfo> _info) const | ||
| Json::Value ASTJsonConverter::inlineAssemblyIdentifierToJson(pair<yul::Identifier const*, InlineAssemblyAnnotation::ExternalIdentifierInfo> _info) const | ||
| { | ||
| Json::Value tuple(Json::objectValue); | ||
| tuple["src"] = sourceLocationToString(_info.first->debugData->location); | ||
| tuple["src"] = sourceLocationToString(nativeLocationOf(*_info.first)); | ||
|
Comment on lines
-174
to
+177
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changing this to |
||
| tuple["declaration"] = idOrNull(_info.second.declaration); | ||
| tuple["isSlot"] = Json::Value(_info.second.suffix == "slot"); | ||
| tuple["isOffset"] = Json::Value(_info.second.suffix == "offset"); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.