-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Derive the SILDebugScope for a variable declaration from its owning ASTScope. #65783
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
Derive the SILDebugScope for a variable declaration from its owning ASTScope. #65783
Conversation
@swift-ci test |
8ae7d5e
to
a3bf1f8
Compare
@swift-ci test |
@swift-ci test |
1 similar comment
@swift-ci test |
6945902
to
b3052f4
Compare
@swift-ci test |
test with swiftlang/llvm-project#6827 |
b3052f4
to
8af6917
Compare
test with swiftlang/llvm-project#6827 |
2 similar comments
test with swiftlang/llvm-project#6827 |
test with swiftlang/llvm-project#6827 |
lib/SILGen/SILGenFunction.cpp
Outdated
// Collect all variable declarations in this scope. | ||
struct Consumer : public namelookup::AbstractASTScopeDeclConsumer { | ||
const ast_scope::ASTScopeImpl *ASTScope; | ||
VarDeclScopeMapTy& VarDeclScopeMap; |
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.
Should this be a multi-map in case the VarDecl appears in more than one scope?
bool consume(ArrayRef<ValueDecl *> values, | ||
NullablePtr<DeclContext> baseDC) override { | ||
for (auto &value : values) | ||
VarDeclScopeMap.insert({value, ASTScope}); |
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 assert here that we didn't have a duplicate?
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.
Done. (And fixed a few missed caching opportunities along the way).
…STScope. The previous code made the assumption that the ASTScope for a variable declaration should be the one of the declaration's source location. That is not necessarily the case, in some cases it should be an ancestor scope. This patch introduces a map from ValueDecl -> ASTScope that is derived from querying each ASTScope for its locals, which matches also what happens in name lookup. This patch also fixes the nesting of SILDebugScopes created for guard statement bodies, which are incorrectly nested in the ASTScope hierarchy. rdar://108940570
test with swiftlang/llvm-project#6827 |
8af6917
to
07b60f1
Compare
(pushed to the wrong branch previously) |
test with swiftlang/llvm-project#6827 |
rdar://108940570