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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/AST/ASTWalker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
}

bool shouldSkip(Decl *D) {
if (isa<VarDecl>(D)) {
if (auto *VD = dyn_cast<VarDecl>(D)) {
// VarDecls are walked via their NamedPattern, ignore them if we encounter
// then in the few cases where they are also pushed outside as members.
// In all those cases we can walk them via the pattern binding decl.
Expand All @@ -1250,8 +1250,8 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
if (Walker.Parent.getAsModule() &&
D->getDeclContext()->getParentSourceFile())
return true;
if (Decl *ParentD = Walker.Parent.getAsDecl())
return (isa<NominalTypeDecl>(ParentD) || isa<ExtensionDecl>(ParentD));
if (Walker.Parent.getAsDecl() && VD->getParentPatternBinding())
return true;
auto walkerParentAsStmt = Walker.Parent.getAsStmt();
if (walkerParentAsStmt && isa<BraceStmt>(walkerParentAsStmt))
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@import Foundation;

@class Foo;

@interface Foo : NSObject

@property (nullable, strong, nonatomic) NSDate *today;

- (void)selectDate:(nullable NSDate *)date;

@end

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
framework module ObjcProperty {
header "ObjcProperty.h"
export *
}
13 changes: 13 additions & 0 deletions test/SymbolGraph/ClangImporter/ObjcProperty.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// RUN: %empty-directory(%t)
// RUN: cp -r %S/Inputs/ObjcProperty/ObjcProperty.framework %t
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-objc-interop -emit-module -o %t/ObjcProperty.framework/Modules/ObjcProperty.swiftmodule/%target-swiftmodule-name -import-underlying-module -F %t -module-name ObjcProperty -disable-objc-attr-requires-foundation-module %s
// RUN: %target-swift-symbolgraph-extract -sdk %clang-importer-sdk -module-name ObjcProperty -F %t -output-dir %t -pretty-print -v
// RUN: %FileCheck %s --input-file %t/ObjcProperty.symbols.json

// REQUIRES: objc_interop

import Foundation

public enum SwiftEnum {}

// CHECK: "precise": "c:objc(cs)Foo(py)today"