Skip to content

Commit 458ed30

Browse files
Merge pull request #38394 from apple/QuietMisdreavus/clang-walk
* don't skip walking VarDecls from parent clang nodes rdar://80235766
2 parents 63c6f98 + 6887212 commit 458ed30

File tree

6 files changed

+32
-3
lines changed

6 files changed

+32
-3
lines changed

lib/AST/ASTWalker.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
12411241
}
12421242

12431243
bool shouldSkip(Decl *D) {
1244-
if (isa<VarDecl>(D)) {
1244+
if (auto *VD = dyn_cast<VarDecl>(D)) {
12451245
// VarDecls are walked via their NamedPattern, ignore them if we encounter
12461246
// then in the few cases where they are also pushed outside as members.
12471247
// In all those cases we can walk them via the pattern binding decl.
@@ -1250,8 +1250,8 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
12501250
if (Walker.Parent.getAsModule() &&
12511251
D->getDeclContext()->getParentSourceFile())
12521252
return true;
1253-
if (Decl *ParentD = Walker.Parent.getAsDecl())
1254-
return (isa<NominalTypeDecl>(ParentD) || isa<ExtensionDecl>(ParentD));
1253+
if (Walker.Parent.getAsDecl() && VD->getParentPatternBinding())
1254+
return true;
12551255
auto walkerParentAsStmt = Walker.Parent.getAsStmt();
12561256
if (walkerParentAsStmt && isa<BraceStmt>(walkerParentAsStmt))
12571257
return true;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@import Foundation;
2+
3+
@class Foo;
4+
5+
@interface Foo : NSObject
6+
7+
@property (nullable, strong, nonatomic) NSDate *today;
8+
9+
- (void)selectDate:(nullable NSDate *)date;
10+
11+
@end
12+

test/SymbolGraph/ClangImporter/Inputs/ObjcProperty/ObjcProperty.framework/Modules/ObjcProperty.swiftmodule/.keep

Whitespace-only changes.

test/SymbolGraph/ClangImporter/Inputs/ObjcProperty/ObjcProperty.framework/ObjcProperty

Whitespace-only changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
framework module ObjcProperty {
2+
header "ObjcProperty.h"
3+
export *
4+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: cp -r %S/Inputs/ObjcProperty/ObjcProperty.framework %t
3+
// 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
4+
// RUN: %target-swift-symbolgraph-extract -sdk %clang-importer-sdk -module-name ObjcProperty -F %t -output-dir %t -pretty-print -v
5+
// RUN: %FileCheck %s --input-file %t/ObjcProperty.symbols.json
6+
7+
// REQUIRES: objc_interop
8+
9+
import Foundation
10+
11+
public enum SwiftEnum {}
12+
13+
// CHECK: "precise": "c:objc(cs)Foo(py)today"

0 commit comments

Comments
 (0)