Skip to content

[AST] don't skip walking VarDecls from parent clang nodes #38394

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

Merged
merged 2 commits into from
Jul 19, 2021

Conversation

QuietMisdreavus
Copy link
Contributor

Resolves rdar://80235766

The ASTWalker skips VarDecl nodes that it thinks have PatternBindingDecls that can be walked later. However, this excludes decls that came from Clang modules, which includes Objective-C properties. This causes some of these properties to be missing when rendered into a symbol graph. This PR prevents the ASTWalker from skipping VarDecls whose parent Decls have Clang nodes.

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please test

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please build toolchain macOS platform

@@ -1251,7 +1251,7 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
D->getDeclContext()->getParentSourceFile())
return true;
if (Decl *ParentD = Walker.Parent.getAsDecl())
return (isa<NominalTypeDecl>(ParentD) || isa<ExtensionDecl>(ParentD));
return (!D->hasClangNode() && (isa<NominalTypeDecl>(ParentD) || isa<ExtensionDecl>(ParentD)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did checking D->getParentPatternBinding() not work here? I'm concerned we'll still visit some VarDecls twice because the ClangImporter does seem to create PBDs for some VarDecls.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Casting to a VarDecl and checking for VD->getParentPatternBinding() caused availability checking to start erroneously failing, preventing the standard library from building (and failing a bunch of tests as well).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it only check for the parent pattern binding if the parent is a decl, i.e. in the branch i edited?

@QuietMisdreavus
Copy link
Contributor Author

Unrelated CI error.

@swift-ci Please test

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please build toolchain macOS platform

@swiftlang swiftlang deleted a comment from swift-ci Jul 15, 2021
@swiftlang swiftlang deleted a comment from swift-ci Jul 15, 2021
@swift-ci
Copy link
Contributor

macOS Toolchain
Download Toolchain
Git Sha - f53a135

Install command
tar -zxf swift-PR-38394-1055-osx.tar.gz --directory ~/

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please test

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please build toolchain macOS platform

@swift-ci
Copy link
Contributor

macOS Toolchain
Download Toolchain
Git Sha - 6887212

Install command
tar -zxf swift-PR-38394-1056-osx.tar.gz --directory ~/

@QuietMisdreavus QuietMisdreavus merged commit 458ed30 into main Jul 19, 2021
@QuietMisdreavus QuietMisdreavus deleted the QuietMisdreavus/clang-walk branch July 19, 2021 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants