Skip to content

Commit e24f126

Browse files
[SymbolGraph] don't emit symbols for implicit inherited initializers (#41985)
rdar://90401347
1 parent b3b080e commit e24f126

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

lib/SymbolGraphGen/SymbolGraph.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,12 @@ bool SymbolGraph::canIncludeDeclAsNode(const Decl *D) const {
679679
if (D->getModuleContext()->getName() != M.getName() && !Walker.isFromExportedImportedModule(D)) {
680680
return false;
681681
}
682-
683-
if (!isa<ValueDecl>(D)) {
682+
683+
if (const auto *VD = dyn_cast<ValueDecl>(D)) {
684+
if (VD->getOverriddenDecl() && D->isImplicit()) {
685+
return false;
686+
}
687+
} else {
684688
return false;
685689
}
686690
return !isImplicitlyPrivate(cast<ValueDecl>(D))

test/SymbolGraph/ClangImporter/ObjcProperty.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,25 @@
33
// 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
44
// RUN: %target-swift-symbolgraph-extract -sdk %clang-importer-sdk -module-name ObjcProperty -F %t -output-dir %t -pretty-print -v
55
// RUN: %FileCheck %s --input-file %t/ObjcProperty.symbols.json
6+
// RUN: %FileCheck %s --input-file %t/ObjcProperty.symbols.json --check-prefix XLANG
67

78
// REQUIRES: objc_interop
89

910
import Foundation
1011

1112
public enum SwiftEnum {}
1213

14+
public class SwiftClass : Foo {}
15+
16+
// ensure that synthesized inherited objc symbols do not appear in the symbol graph
17+
18+
// CHECK-NOT: "c:objc(cs)NSObject(im)init"
19+
20+
// ensure that children of clang nodes appear in the symbol graph
21+
1322
// CHECK: "precise": "c:objc(cs)Foo(py)today"
23+
24+
// ensure that a swift class that inherits from an objc class still doesn't generate inherited
25+
// symbols
26+
27+
// XLANG-COUNT-2: selectDate:

test/SymbolGraph/Relationships/Synthesized/SuperclassImplementation.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,14 @@ public class Base {
1919

2020
public class Derived: Base {
2121
// CHECK-NOT: "precise": "s:24SuperclassImplementation4BaseC3fooyyF::SYNTHESIZED::s:24SuperclassImplementation7DerivedC"
22+
23+
// Also skip synthesized constructors
24+
// CHECK-NOT: "precise": "s:24SuperclassImplementation7DerivedCACycfc"
2225
}
2326

2427
public class DerivedDerived: Derived {
2528
// CHECK-NOT: "precise": "s:24SuperclassImplementation4BaseC3fooyyF::SYNTHESIZED::s:24SuperclassImplementation07DerivedC0C"
29+
30+
// Also skip synthesized constructors
31+
// CHECK-NOT: "precise": "s:24SuperclassImplementation07DerivedC0CACycfc"
2632
}

0 commit comments

Comments
 (0)