Skip to content

Commit 3caea44

Browse files
stop considering clang modules to be different for re-exporting
rdar://98808363 functionally reverts #58421
1 parent ae7f9b1 commit 3caea44

File tree

8 files changed

+45
-8
lines changed

8 files changed

+45
-8
lines changed

lib/SymbolGraphGen/SymbolGraphASTWalker.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,10 @@ namespace {
2525

2626
/// Compare the two \c ModuleDecl instances to see whether they are the same.
2727
///
28-
/// Pass \c true to the \c ignoreUnderlying argument to consider two modules the same even if
29-
/// one is a Swift module and the other a non-Swift module. This allows a Swift module and its
30-
/// underlying Clang module to compare as equal.
31-
bool areModulesEqual(const ModuleDecl *lhs, const ModuleDecl *rhs, bool ignoreUnderlying = false) {
32-
return lhs->getNameStr() == rhs->getNameStr()
33-
&& (ignoreUnderlying || lhs->isNonSwiftModule() == rhs->isNonSwiftModule());
28+
/// This does a by-name comparison to consider a module's underlying Clang module to be equivalent
29+
/// to the wrapping module of the same name.
30+
bool areModulesEqual(const ModuleDecl *lhs, const ModuleDecl *rhs) {
31+
return lhs->getNameStr() == rhs->getNameStr();
3432
}
3533

3634
} // anonymous namespace
@@ -64,10 +62,10 @@ SymbolGraph *SymbolGraphASTWalker::getModuleSymbolGraph(const Decl *D) {
6462
}
6563
}
6664

67-
if (areModulesEqual(&this->M, M, true)) {
65+
if (areModulesEqual(&this->M, M)) {
6866
return &MainGraph;
6967
} else if (MainGraph.DeclaringModule.hasValue() &&
70-
areModulesEqual(MainGraph.DeclaringModule.getValue(), M, true)) {
68+
areModulesEqual(MainGraph.DeclaringModule.getValue(), M)) {
7169
// Cross-import overlay modules already appear as "extensions" of their declaring module; we
7270
// should put actual extensions of that module into the main graph
7371
return &MainGraph;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: cp -r %S/Inputs/ExportedImport/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 %S/Inputs/ExportedImport/A.swift
4+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-objc-interop -emit-module -o %t/ExportedImport.swiftmodule -F %t -module-name ExportedImport %s -emit-symbol-graph -emit-symbol-graph-dir %t
5+
// wait: false
6+
// RUN: %FileCheck %s --input-file %t/ExportedImport.symbols.json
7+
8+
// REQUIRES: objc_interop
9+
10+
// CHECK-DAG: "precise":"s:So11ClangStructa12ObjcPropertyE05InnerB0V"
11+
12+
@_exported import ObjcProperty
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
extension SwiftStruct {
2+
public struct InnerStruct {}
3+
}
4+
5+
extension SwiftStruct.InnerStruct {
6+
public struct NestedStruct {}
7+
}
8+
9+
public protocol SomeProtocol {}
10+
11+
extension SomeProtocol {
12+
public func someFunc() {}
13+
}
14+
15+
extension SwiftStruct.InnerStruct.NestedStruct: SomeProtocol {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
Name: ObjcProperty
3+
Typedefs:
4+
- Name: ClangStruct
5+
SwiftName: SwiftStruct
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
typedef struct {
2+
unsigned filler;
3+
} ClangStruct;

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

Whitespace-only changes.

test/SymbolGraph/ClangImporter/Inputs/ExportedImport/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+
}

0 commit comments

Comments
 (0)