Skip to content

Revert "[AST] scan @_exported import modules of source files for display decls" #40877

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
merged 1 commit into from
Jan 17, 2022
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
4 changes: 0 additions & 4 deletions include/swift/AST/FileUnit.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "swift/AST/Module.h"
#include "swift/AST/RawComment.h"
#include "swift/Basic/BasicSourceInfo.h"
#include "swift/Basic/Debug.h"

#include "llvm/ADT/PointerIntPair.h"

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

SWIFT_DEBUG_DUMPER(dumpDisplayDecls());
SWIFT_DEBUG_DUMPER(dumpTopLevelDecls());

/// Traverse the decls within this file.
///
/// \returns true if traversal was aborted, false if it completed
Expand Down
4 changes: 0 additions & 4 deletions include/swift/AST/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "swift/AST/Type.h"
#include "swift/Basic/BasicSourceInfo.h"
#include "swift/Basic/Compiler.h"
#include "swift/Basic/Debug.h"
#include "swift/Basic/OptionSet.h"
#include "swift/Basic/STLExtras.h"
#include "swift/Basic/SourceLoc.h"
Expand Down Expand Up @@ -857,9 +856,6 @@ class ModuleDecl
/// transferred from module files to the dSYMs, remove this.
bool isExternallyConsumed() const;

SWIFT_DEBUG_DUMPER(dumpDisplayDecls());
SWIFT_DEBUG_DUMPER(dumpTopLevelDecls());

SourceRange getSourceRange() const { return SourceRange(); }

static bool classof(const DeclContext *DC) {
Expand Down
4 changes: 0 additions & 4 deletions include/swift/AST/SourceFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,6 @@ class SourceFile final : public FileUnit {

~SourceFile();

bool hasImports() const {
return Imports.hasValue();
}

/// Retrieve an immutable view of the source file's imports.
ArrayRef<AttributedImport<ImportedModule>> getImports() const {
return *Imports;
Expand Down
65 changes: 0 additions & 65 deletions lib/AST/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,22 +780,6 @@ void SourceFile::lookupObjCMethods(
results.append(known->second.begin(), known->second.end());
}

static void collectParsedExportedImports(const ModuleDecl *M, SmallPtrSetImpl<ModuleDecl *> &Imports) {
for (const FileUnit *file : M->getFiles()) {
if (const SourceFile *source = dyn_cast<SourceFile>(file)) {
if (source->hasImports()) {
for (auto import : source->getImports()) {
if (import.options.contains(ImportFlags::Exported)) {
if (!Imports.contains(import.module.importedModule)) {
Imports.insert(import.module.importedModule);
}
}
}
}
}
}
}

void ModuleDecl::getLocalTypeDecls(SmallVectorImpl<TypeDecl*> &Results) const {
FORWARD(getLocalTypeDecls, (Results));
}
Expand All @@ -804,24 +788,6 @@ void ModuleDecl::getTopLevelDecls(SmallVectorImpl<Decl*> &Results) const {
FORWARD(getTopLevelDecls, (Results));
}

void ModuleDecl::dumpDisplayDecls() const {
SmallVector<Decl *, 32> Decls;
getDisplayDecls(Decls);
for (auto *D : Decls) {
D->dump(llvm::errs());
llvm::errs() << "\n";
}
}

void ModuleDecl::dumpTopLevelDecls() const {
SmallVector<Decl *, 32> Decls;
getTopLevelDecls(Decls);
for (auto *D : Decls) {
D->dump(llvm::errs());
llvm::errs() << "\n";
}
}

void ModuleDecl::getExportedPrespecializations(
SmallVectorImpl<Decl *> &Results) const {
FORWARD(getExportedPrespecializations, (Results));
Expand Down Expand Up @@ -942,23 +908,8 @@ SourceFile::getExternalRawLocsForDecl(const Decl *D) const {
}

void ModuleDecl::getDisplayDecls(SmallVectorImpl<Decl*> &Results) const {
if (isParsedModule(this)) {
SmallPtrSet<ModuleDecl *, 4> Modules;
collectParsedExportedImports(this, Modules);
for (const ModuleDecl *import : Modules) {
import->getDisplayDecls(Results);
}
}
// FIXME: Should this do extra access control filtering?
FORWARD(getDisplayDecls, (Results));

#ifndef NDEBUG
llvm::DenseSet<Decl *> visited;
for (auto *D : Results) {
auto inserted = visited.insert(D).second;
assert(inserted && "there should be no duplicate decls");
}
#endif
}

ProtocolConformanceRef
Expand Down Expand Up @@ -3111,22 +3062,6 @@ void FileUnit::getTopLevelDeclsWhereAttributesMatch(
Results.erase(newEnd, Results.end());
}

void FileUnit::dumpDisplayDecls() const {
SmallVector<Decl *, 32> Decls;
getDisplayDecls(Decls);
for (auto *D : Decls) {
D->dump(llvm::errs());
}
}

void FileUnit::dumpTopLevelDecls() const {
SmallVector<Decl *, 32> Decls;
getTopLevelDecls(Decls);
for (auto *D : Decls) {
D->dump(llvm::errs());
}
}

void swift::simple_display(llvm::raw_ostream &out, const FileUnit *file) {
if (!file) {
out << "(null)";
Expand Down
6 changes: 1 addition & 5 deletions test/SymbolGraph/ClangImporter/EmitWhileBuilding.swift
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
// RUN: %empty-directory(%t)
// RUN: cp -r %S/Inputs/EmitWhileBuilding/EmitWhileBuilding.framework %t
// 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
// 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
// RUN: %{python} -m json.tool %t/EmitWhileBuilding.symbols.json %t/EmitWhileBuilding.formatted.symbols.json
// RUN: %FileCheck %s --input-file %t/EmitWhileBuilding.formatted.symbols.json
// RUN: %FileCheck %s --input-file %t/EmitWhileBuilding.formatted.symbols.json --check-prefix HEADER

// REQUIRES: objc_interop

import Foundation

public enum SwiftEnum {}

// HEADER: "precise": "c:@testVariable"

// CHECK: "precise": "s:17EmitWhileBuilding9SwiftEnumO",
// CHECK: "declarationFragments": [
// CHECK-NEXT: {
// CHECK-NEXT: "kind": "keyword",
Expand Down

This file was deleted.