Skip to content

Revert "[cxx-interop] Fix two issues with extending nested types across modules." #40481

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
Dec 9, 2021
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 lib/ClangImporter/ClangImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2547,10 +2547,6 @@ static bool isVisibleFromModule(const ClangModuleUnit *ModuleFilter,
auto *Importer = static_cast<ClangImporter *>(Ctx.getClangModuleLoader());
auto ClangNode = Importer->getEffectiveClangNode(VD);

// Decls in the __ObjC bridging header is always visible.
if (VD->getModuleContext() == Importer->getImportedHeaderModule())
return true;

// Macros can be "redeclared" by putting an equivalent definition in two
// different modules. (We don't actually check the equivalence.)
// FIXME: We're also not checking if the redeclaration is in /this/ module.
Expand Down
5 changes: 0 additions & 5 deletions lib/ClangImporter/ImportDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2473,11 +2473,6 @@ namespace {
for (auto redecl : decl->redecls())
Impl.ImportedDecls[{redecl, getVersion()}] = enumDecl;

// Because a namespaces's decl context is the bridging header, make sure
// we add them to the bridging header lookup table.
addEntryToLookupTable(*Impl.BridgingHeaderLookupTable,
const_cast<clang::NamespaceDecl *>(decl),
Impl.getNameImporter());
return enumDecl;
}

Expand Down
6 changes: 3 additions & 3 deletions lib/ClangImporter/ImporterImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,9 @@ class LLVM_LIBRARY_VISIBILITY ClangImporter::Implementation
"<bridging-header-import>";

private:
/// The Swift lookup table for the bridging header.
std::unique_ptr<SwiftLookupTable> BridgingHeaderLookupTable;

/// The Swift lookup tables, per module.
///
/// Annoyingly, we list this table early so that it gets torn down after
Expand Down Expand Up @@ -426,9 +429,6 @@ class LLVM_LIBRARY_VISIBILITY ClangImporter::Implementation
llvm::SmallDenseMap<ModuleDecl *, SourceFile *> ClangSwiftAttrSourceFiles;

public:
/// The Swift lookup table for the bridging header.
std::unique_ptr<SwiftLookupTable> BridgingHeaderLookupTable;

/// Mapping of already-imported declarations.
llvm::DenseMap<std::pair<const clang::Decl *, Version>, Decl *> ImportedDecls;

Expand Down
13 changes: 2 additions & 11 deletions test/IDE/complete_from_clang_framework.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@ func testSwiftCompletions(foo: SwiftStruct) {
// CLANG_BAR-DAG: Decl[GlobalVar]/OtherModule[Bar]: BAR_MACRO_1[#Int32#]{{; name=.+$}}
// CLANG_BAR-DAG: Decl[Struct]/OtherModule[Bar]: SomeItemSet[#SomeItemSet#]
// CLANG_BAR-DAG: Decl[TypeAlias]/OtherModule[Bar]: SomeEnvironment[#SomeItemSet#]
// CLANG_BAR-DAG: Decl[TypeAlias]/OtherModule[__ObjC]: __NSConstantString[#__NSConstantString_tag#]; name=__NSConstantString
// CLANG_BAR-DAG: Decl[TypeAlias]/OtherModule[__ObjC]: __builtin_ms_va_list[#UnsafeMutablePointer<CChar>#]; name=__builtin_ms_va_list
// CLANG_BAR-DAG: Decl[TypeAlias]/OtherModule[__ObjC]: __builtin_va_list[#(__va_list_tag)#]; name=__builtin_va_list
// CLANG_BAR: End completions

// CLANG_BOTH_FOO_BAR: Begin completions
Expand All @@ -154,15 +151,12 @@ func testCompleteModuleQualifiedFoo2() {
Foo#^CLANG_QUAL_FOO_2^#
// If the number of results below changes, then you need to add a result to the
// list below.
// CLANG_QUAL_FOO_2: Begin completions, 82 items
// CLANG_QUAL_FOO_2: Begin completions, 76 items
// CLANG_QUAL_FOO_2-DAG: Decl[Class]/OtherModule[Foo]: .FooClassBase[#FooClassBase#]{{; name=.+$}}
// CLANG_QUAL_FOO_2-DAG: Decl[Class]/OtherModule[Foo]: .FooClassDerived[#FooClassDerived#]{{; name=.+$}}
// CLANG_QUAL_FOO_2-DAG: Decl[Class]/OtherModule[Foo]: .ClassWithInternalProt[#ClassWithInternalProt#]{{; name=.+$}}
// CLANG_QUAL_FOO_2-DAG: Decl[Struct]/OtherModule[Foo]: ._InternalStruct[#_InternalStruct#]
// CLANG_QUAL_FOO_2-DAG: Decl[Class]/OtherModule[Foo]: .FooClassPropertyOwnership[#FooClassPropertyOwnership#]{{; name=.+$}}
// CLANG_QUAL_FOO_2-DAG: Decl[TypeAlias]/OtherModule[__ObjC]: .__NSConstantString[#__NSConstantString_tag#]; name=__NSConstantString
// CLANG_QUAL_FOO_2-DAG: Decl[TypeAlias]/OtherModule[__ObjC]: .__builtin_ms_va_list[#UnsafeMutablePointer<CChar>#]; name=__builtin_ms_va_list
// CLANG_QUAL_FOO_2-DAG: Decl[TypeAlias]/OtherModule[__ObjC]: .__builtin_va_list[#(__va_list_tag)#]; name=__builtin_va_list
// CLANG_QUAL_FOO_2-DAG: Decl[FreeFunction]/OtherModule[Foo]: ._internalTopLevelFunc()[#Void#]
// CLANG_QUAL_FOO_2-DAG: Decl[Enum]/OtherModule[Foo]: .FooComparisonResult[#FooComparisonResult#]{{; name=.+$}}
// CLANG_QUAL_FOO_2-DAG: Decl[FreeFunction]/OtherModule[Foo]: .fooFunc1({#(a): Int32#})[#Int32#]{{; name=.+$}}
Expand Down Expand Up @@ -226,17 +220,14 @@ func testCompleteModuleQualifiedFoo2() {
// CLANG_QUAL_FOO_2-DAG: Decl[Class]/OtherModule[Foo]: .FooRepeatedMembers[#FooRepeatedMembers#]{{; name=.+$}}
// CLANG_QUAL_FOO_2-DAG: Decl[Class]/OtherModule[Foo]: .FooClassWithClassProperties[#FooClassWithClassProperties#];
// CLANG_QUAL_FOO_2-DAG: Decl[Enum]/OtherModule[Foo]: .SCNFilterMode[#SCNFilterMode#];
// CLANG_QUAL_FOO_2-DAG: Decl[TypeAlias]/OtherModule[__ObjC]: .__NSConstantString[#__NSConstantString_tag#]; name=__NSConstantString
// CLANG_QUAL_FOO_2-DAG: Decl[TypeAlias]/OtherModule[__ObjC]: .__builtin_ms_va_list[#UnsafeMutablePointer<CChar>#]; name=__builtin_ms_va_list
// CLANG_QUAL_FOO_2-DAG: Decl[TypeAlias]/OtherModule[__ObjC]: .__builtin_va_list[#(__va_list_tag)#]; name=__builtin_va_list
// CLANG_QUAL_FOO_2: End completions
}

func testCompleteModuleQualifiedBar1() {
Bar.#^CLANG_QUAL_BAR_1^#
// If the number of results below changes, this is an indication that you need
// to add a result to the appropriate list. Do not just bump the number!
// CLANG_QUAL_BAR_1: Begin completions, 11 items
// CLANG_QUAL_BAR_1: Begin completions, 8 items
}

func testCompleteFunctionCall1() {
Expand Down
12 changes: 0 additions & 12 deletions test/Interop/Cxx/modules/Inputs/bridge-header.h

This file was deleted.

4 changes: 0 additions & 4 deletions test/Interop/Cxx/modules/Inputs/module.modulemap

This file was deleted.

13 changes: 0 additions & 13 deletions test/Interop/Cxx/modules/Inputs/namespace-extension-lib.swift

This file was deleted.

18 changes: 0 additions & 18 deletions test/Interop/Cxx/modules/Inputs/namespace.h

This file was deleted.

This file was deleted.

26 changes: 0 additions & 26 deletions test/Interop/Cxx/modules/use-namespace-extension-lib.swift

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions test/Interop/Cxx/namespace/templates-module-interface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
// CHECK-NEXT: }
// CHECK-NEXT: typealias ForwardDeclaredClassTemplateOutOfLineChar = TemplatesNS1.TemplatesNS2.__CxxTemplateInstN12TemplatesNS112TemplatesNS237ForwardDeclaredClassTemplateOutOfLineIcEE
// CHECK-NEXT: enum TemplatesNS4 {
// CHECK-NEXT: struct __CxxTemplateInstN12TemplatesNS417HasSpecializationIiEE {
// CHECK-NEXT: struct __CxxTemplateInstN12TemplatesNS417HasSpecializationIcEE {
// CHECK-NEXT: init()
// CHECK-NEXT: }
// CHECK-NEXT: struct __CxxTemplateInstN12TemplatesNS417HasSpecializationIcEE {
// CHECK-NEXT: struct __CxxTemplateInstN12TemplatesNS417HasSpecializationIiEE {
// CHECK-NEXT: init()
// CHECK-NEXT: }
// CHECK-NEXT: struct HasSpecialization<> {
Expand Down