Skip to content

Commit add0915

Browse files
SourceFile::getDisplayDecls also walks @_exported imports
1 parent 9880686 commit add0915

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

include/swift/AST/SourceFile.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,8 @@ class SourceFile final : public FileUnit {
393393
public:
394394
virtual void getTopLevelDecls(SmallVectorImpl<Decl*> &results) const override;
395395

396+
virtual void getDisplayDecls(SmallVectorImpl<Decl*> &results) const override;
397+
396398
virtual void
397399
getOperatorDecls(SmallVectorImpl<OperatorDecl *> &results) const override;
398400

lib/AST/Module.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,17 @@ void SourceFile::getTopLevelDecls(SmallVectorImpl<Decl*> &Results) const {
822822
Results.append(decls.begin(), decls.end());
823823
}
824824

825+
void SourceFile::getDisplayDecls(SmallVectorImpl<Decl*> &Results) const {
826+
if (Imports.hasValue()) {
827+
for (auto import : *Imports) {
828+
if (import.options.contains(ImportFlags::Exported)) {
829+
import.module.importedModule->getDisplayDecls(Results);
830+
}
831+
}
832+
}
833+
getTopLevelDecls(Results);
834+
}
835+
825836
void ModuleDecl::getOperatorDecls(
826837
SmallVectorImpl<OperatorDecl *> &results) const {
827838
// For a parsed module, we can check the source cache on the module rather

test/SymbolGraph/ClangImporter/EmitWhileBuilding.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-objc-interop -emit-module-path %t/EmitWhileBuilding.framework/Modules/EmitWhileBuilding.swiftmodule/%target-swiftmodule-name -import-underlying-module -F %t -module-name EmitWhileBuilding -disable-objc-attr-requires-foundation-module %s -emit-symbol-graph -emit-symbol-graph-dir %t
44
// RUN: %{python} -m json.tool %t/EmitWhileBuilding.symbols.json %t/EmitWhileBuilding.formatted.symbols.json
55
// RUN: %FileCheck %s --input-file %t/EmitWhileBuilding.formatted.symbols.json
6+
// RUN: %FileCheck %s --input-file %t/EmitWhileBuilding.formatted.symbols.json --check-prefix HEADER
67

78
// REQUIRES: objc_interop
89

910
import Foundation
1011

1112
public enum SwiftEnum {}
1213

14+
// HEADER: "precise": "c:@testVariable"
15+
16+
// CHECK: "precise": "s:17EmitWhileBuilding9SwiftEnumO",
1317
// CHECK: "declarationFragments": [
1418
// CHECK-NEXT: {
1519
// CHECK-NEXT: "kind": "keyword",

0 commit comments

Comments
 (0)