Skip to content

[6.0][🍒] Avoid recursing into non swift modules when collecting exported imports #75621

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
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
2 changes: 2 additions & 0 deletions lib/AST/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1540,6 +1540,8 @@ collectExportedImports(const ModuleDecl *topLevelModule,
stack.push_back(topLevelModule);
while (!stack.empty()) {
const ModuleDecl *module = stack.pop_back_val();
if (module->isNonSwiftModule())
continue;

for (const FileUnit *file : module->getFiles()) {
if (const SourceFile *source = dyn_cast<SourceFile>(file)) {
Expand Down
18 changes: 12 additions & 6 deletions test/SymbolGraph/ClangImporter/ObjcProperty.swift
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
// RUN: %empty-directory(%t)
// RUN: %empty-directory(%t1)
// 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
// RUN: %FileCheck %s --input-file %t/ObjcProperty.symbols.json --check-prefix XLANG
// 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 -emit-symbol-graph -emit-symbol-graph-dir %t
// RUN: %target-swift-symbolgraph-extract -sdk %clang-importer-sdk -module-name ObjcProperty -F %t -output-dir %t1 -pretty-print -v
// RUN: %validate-json %t/ObjcProperty.symbols.json %t/ObjcProperty.formatted.symbols.json
// RUN: %FileCheck %s --input-file %t/ObjcProperty.formatted.symbols.json
// RUN: %FileCheck %s --input-file %t/ObjcProperty.formatted.symbols.json --check-prefix XLANG
// RUN: %FileCheck %s --input-file %t1/ObjcProperty.symbols.json
// RUN: %FileCheck %s --input-file %t1/ObjcProperty.symbols.json --check-prefix XLANG

// REQUIRES: objc_interop

import Foundation

public enum SwiftEnum {}

public class SwiftClass : Foo {}

// ensure we don't accidentaly pull in exported objc modules

// CHECK-NOT: "precise": "c:objc(cs)NSString"

// ensure that synthesized inherited objc symbols do not appear in the symbol graph

// CHECK-NOT: "c:objc(cs)NSObject(im)init"
Expand Down