Skip to content

Commit caf2f08

Browse files
authored
Merge pull request #40877 from apple/revert-40810-QuietMisdreavus/sourcefile-export
Revert "[AST] scan `@_exported import` modules of source files for display decls"
2 parents 5a9abb2 + 05a4c57 commit caf2f08

File tree

6 files changed

+1
-83
lines changed

6 files changed

+1
-83
lines changed

include/swift/AST/FileUnit.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "swift/AST/Module.h"
1717
#include "swift/AST/RawComment.h"
1818
#include "swift/Basic/BasicSourceInfo.h"
19-
#include "swift/Basic/Debug.h"
2019

2120
#include "llvm/ADT/PointerIntPair.h"
2221

@@ -309,9 +308,6 @@ class FileUnit : public DeclContext, public ASTAllocated<FileUnit> {
309308
return getParentModule()->getRealName().str();
310309
}
311310

312-
SWIFT_DEBUG_DUMPER(dumpDisplayDecls());
313-
SWIFT_DEBUG_DUMPER(dumpTopLevelDecls());
314-
315311
/// Traverse the decls within this file.
316312
///
317313
/// \returns true if traversal was aborted, false if it completed

include/swift/AST/Module.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include "swift/AST/Type.h"
2727
#include "swift/Basic/BasicSourceInfo.h"
2828
#include "swift/Basic/Compiler.h"
29-
#include "swift/Basic/Debug.h"
3029
#include "swift/Basic/OptionSet.h"
3130
#include "swift/Basic/STLExtras.h"
3231
#include "swift/Basic/SourceLoc.h"
@@ -857,9 +856,6 @@ class ModuleDecl
857856
/// transferred from module files to the dSYMs, remove this.
858857
bool isExternallyConsumed() const;
859858

860-
SWIFT_DEBUG_DUMPER(dumpDisplayDecls());
861-
SWIFT_DEBUG_DUMPER(dumpTopLevelDecls());
862-
863859
SourceRange getSourceRange() const { return SourceRange(); }
864860

865861
static bool classof(const DeclContext *DC) {

include/swift/AST/SourceFile.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,6 @@ class SourceFile final : public FileUnit {
288288

289289
~SourceFile();
290290

291-
bool hasImports() const {
292-
return Imports.hasValue();
293-
}
294-
295291
/// Retrieve an immutable view of the source file's imports.
296292
ArrayRef<AttributedImport<ImportedModule>> getImports() const {
297293
return *Imports;

lib/AST/Module.cpp

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -780,22 +780,6 @@ void SourceFile::lookupObjCMethods(
780780
results.append(known->second.begin(), known->second.end());
781781
}
782782

783-
static void collectParsedExportedImports(const ModuleDecl *M, SmallPtrSetImpl<ModuleDecl *> &Imports) {
784-
for (const FileUnit *file : M->getFiles()) {
785-
if (const SourceFile *source = dyn_cast<SourceFile>(file)) {
786-
if (source->hasImports()) {
787-
for (auto import : source->getImports()) {
788-
if (import.options.contains(ImportFlags::Exported)) {
789-
if (!Imports.contains(import.module.importedModule)) {
790-
Imports.insert(import.module.importedModule);
791-
}
792-
}
793-
}
794-
}
795-
}
796-
}
797-
}
798-
799783
void ModuleDecl::getLocalTypeDecls(SmallVectorImpl<TypeDecl*> &Results) const {
800784
FORWARD(getLocalTypeDecls, (Results));
801785
}
@@ -804,24 +788,6 @@ void ModuleDecl::getTopLevelDecls(SmallVectorImpl<Decl*> &Results) const {
804788
FORWARD(getTopLevelDecls, (Results));
805789
}
806790

807-
void ModuleDecl::dumpDisplayDecls() const {
808-
SmallVector<Decl *, 32> Decls;
809-
getDisplayDecls(Decls);
810-
for (auto *D : Decls) {
811-
D->dump(llvm::errs());
812-
llvm::errs() << "\n";
813-
}
814-
}
815-
816-
void ModuleDecl::dumpTopLevelDecls() const {
817-
SmallVector<Decl *, 32> Decls;
818-
getTopLevelDecls(Decls);
819-
for (auto *D : Decls) {
820-
D->dump(llvm::errs());
821-
llvm::errs() << "\n";
822-
}
823-
}
824-
825791
void ModuleDecl::getExportedPrespecializations(
826792
SmallVectorImpl<Decl *> &Results) const {
827793
FORWARD(getExportedPrespecializations, (Results));
@@ -942,23 +908,8 @@ SourceFile::getExternalRawLocsForDecl(const Decl *D) const {
942908
}
943909

944910
void ModuleDecl::getDisplayDecls(SmallVectorImpl<Decl*> &Results) const {
945-
if (isParsedModule(this)) {
946-
SmallPtrSet<ModuleDecl *, 4> Modules;
947-
collectParsedExportedImports(this, Modules);
948-
for (const ModuleDecl *import : Modules) {
949-
import->getDisplayDecls(Results);
950-
}
951-
}
952911
// FIXME: Should this do extra access control filtering?
953912
FORWARD(getDisplayDecls, (Results));
954-
955-
#ifndef NDEBUG
956-
llvm::DenseSet<Decl *> visited;
957-
for (auto *D : Results) {
958-
auto inserted = visited.insert(D).second;
959-
assert(inserted && "there should be no duplicate decls");
960-
}
961-
#endif
962913
}
963914

964915
ProtocolConformanceRef
@@ -3115,22 +3066,6 @@ void FileUnit::getTopLevelDeclsWhereAttributesMatch(
31153066
Results.erase(newEnd, Results.end());
31163067
}
31173068

3118-
void FileUnit::dumpDisplayDecls() const {
3119-
SmallVector<Decl *, 32> Decls;
3120-
getDisplayDecls(Decls);
3121-
for (auto *D : Decls) {
3122-
D->dump(llvm::errs());
3123-
}
3124-
}
3125-
3126-
void FileUnit::dumpTopLevelDecls() const {
3127-
SmallVector<Decl *, 32> Decls;
3128-
getTopLevelDecls(Decls);
3129-
for (auto *D : Decls) {
3130-
D->dump(llvm::errs());
3131-
}
3132-
}
3133-
31343069
void swift::simple_display(llvm::raw_ostream &out, const FileUnit *file) {
31353070
if (!file) {
31363071
out << "(null)";

test/SymbolGraph/ClangImporter/EmitWhileBuilding.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
// RUN: %empty-directory(%t)
22
// RUN: cp -r %S/Inputs/EmitWhileBuilding/EmitWhileBuilding.framework %t
3-
// 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 %S/Inputs/EmitWhileBuilding/Extra.swift -emit-symbol-graph -emit-symbol-graph-dir %t
3+
// 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
76

87
// REQUIRES: objc_interop
98

109
import Foundation
1110

1211
public enum SwiftEnum {}
1312

14-
// HEADER: "precise": "c:@testVariable"
15-
16-
// CHECK: "precise": "s:17EmitWhileBuilding9SwiftEnumO",
1713
// CHECK: "declarationFragments": [
1814
// CHECK-NEXT: {
1915
// CHECK-NEXT: "kind": "keyword",

test/SymbolGraph/ClangImporter/Inputs/EmitWhileBuilding/Extra.swift

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)