Skip to content

Commit e50230f

Browse files
committed
Merge remote-tracking branch 'origin/main' into rebranch
2 parents a7faeee + 62f26f4 commit e50230f

File tree

9 files changed

+65
-177
lines changed

9 files changed

+65
-177
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,15 @@
165165
/lib/SIL/IR/SILDebug* @adrian-prantl
166166
/lib/SIL/IR/SILLocation* @adrian-prantl
167167
/lib/SIL/IR/SILProfiler.cpp @bnbarham @hamishknight @rintaro
168-
/lib/SILGen/ @jckarter
168+
/lib/SILGen/ @jckarter @kavon
169169
/lib/SILGen/*Availability* @tshortli
170170
/lib/SILGen/*Distributed* @ktoso
171171
/lib/SILOptimizer/ @eeckstein
172172
/lib/SILOptimizer/**/*DebugInfo* @adrian-prantl
173173
/lib/SILOptimizer/Mandatory/ConsumeOperator* @kavon
174174
/lib/SILOptimizer/Mandatory/FlowIsolation.cpp @kavon
175175
/lib/SILOptimizer/Mandatory/MoveOnly* @kavon
176+
/lib/SILOptimizer/Mandatory/AddressLowering* @kavon
176177
/lib/SILOptimizer/Utils/Distributed* @ktoso
177178
/lib/Sema/ @hborla @slavapestov @xedin
178179
/lib/Sema/*Availability* @tshortli

lib/AST/ASTPrinter.cpp

Lines changed: 61 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -2738,87 +2738,72 @@ static void addNamespaceMembers(Decl *decl,
27382738
if (declOwner && declOwner != redeclOwner->getTopLevelModule())
27392739
continue;
27402740
}
2741+
for (auto member : redecl->decls()) {
2742+
if (auto classTemplate = dyn_cast<clang::ClassTemplateDecl>(member)) {
2743+
// Add all specializations to a worklist so we don't accidentally mutate
2744+
// the list of decls we're iterating over.
2745+
llvm::SmallPtrSet<const clang::ClassTemplateSpecializationDecl *, 16> specWorklist;
2746+
for (auto spec : classTemplate->specializations())
2747+
specWorklist.insert(spec);
2748+
for (auto spec : specWorklist) {
2749+
if (auto import =
2750+
ctx.getClangModuleLoader()->importDeclDirectly(spec))
2751+
if (addedMembers.insert(import).second)
2752+
members.push_back(import);
2753+
}
2754+
}
27412755

2742-
std::function<void(clang::DeclContext *)> addDeclsFromContext =
2743-
[&](clang::DeclContext *declContext) {
2744-
for (auto member : declContext->decls()) {
2745-
if (auto classTemplate =
2746-
dyn_cast<clang::ClassTemplateDecl>(member)) {
2747-
// Add all specializations to a worklist so we don't accidentally
2748-
// mutate the list of decls we're iterating over.
2749-
llvm::SmallPtrSet<const clang::ClassTemplateSpecializationDecl *,
2750-
16>
2751-
specWorklist;
2752-
for (auto spec : classTemplate->specializations())
2753-
specWorklist.insert(spec);
2754-
for (auto spec : specWorklist) {
2755-
if (auto import =
2756-
ctx.getClangModuleLoader()->importDeclDirectly(spec))
2757-
if (addedMembers.insert(import).second)
2758-
members.push_back(import);
2759-
}
2756+
auto lookupAndAddMembers = [&](DeclName name) {
2757+
auto allResults = evaluateOrDefault(
2758+
ctx.evaluator, ClangDirectLookupRequest({decl, redecl, name}), {});
2759+
2760+
for (auto found : allResults) {
2761+
auto clangMember = cast<clang::NamedDecl *>(found);
2762+
if (auto importedDecl =
2763+
ctx.getClangModuleLoader()->importDeclDirectly(clangMember)) {
2764+
if (addedMembers.insert(importedDecl).second) {
2765+
members.push_back(importedDecl);
2766+
2767+
// Handle macro-expanded declarations.
2768+
importedDecl->visitAuxiliaryDecls([&](Decl *decl) {
2769+
auto valueDecl = dyn_cast<ValueDecl>(decl);
2770+
if (!valueDecl)
2771+
return;
2772+
2773+
// Bail out if the auxiliary decl was not produced by a macro.
2774+
auto module = decl->getDeclContext()->getParentModule();
2775+
auto *sf = module->getSourceFileContainingLocation(decl->getLoc());
2776+
if (!sf || sf->Kind != SourceFileKind::MacroExpansion)
2777+
return;
2778+
2779+
members.push_back(valueDecl);
2780+
});
27602781
}
2782+
}
2783+
}
2784+
};
27612785

2762-
auto lookupAndAddMembers = [&](clang::NamedDecl *namedDecl) {
2763-
auto name = ctx.getClangModuleLoader()->importName(namedDecl);
2764-
if (!name)
2765-
return;
2766-
2767-
auto allResults = evaluateOrDefault(
2768-
ctx.evaluator, ClangDirectLookupRequest({decl, redecl, name}),
2769-
{});
2770-
2771-
for (auto found : allResults) {
2772-
auto clangMember = cast<clang::NamedDecl *>(found);
2773-
if (auto importedDecl =
2774-
ctx.getClangModuleLoader()->importDeclDirectly(
2775-
clangMember)) {
2776-
if (addedMembers.insert(importedDecl).second) {
2777-
members.push_back(importedDecl);
2778-
2779-
// Handle macro-expanded declarations.
2780-
importedDecl->visitAuxiliaryDecls([&](Decl *decl) {
2781-
auto valueDecl = dyn_cast<ValueDecl>(decl);
2782-
if (!valueDecl)
2783-
return;
2784-
2785-
// Bail out if the auxiliary decl was not produced by a
2786-
// macro.
2787-
auto module = decl->getDeclContext()->getParentModule();
2788-
auto *sf = module->getSourceFileContainingLocation(
2789-
decl->getLoc());
2790-
if (!sf || sf->Kind != SourceFileKind::MacroExpansion)
2791-
return;
2792-
2793-
members.push_back(valueDecl);
2794-
});
2795-
}
2796-
}
2797-
}
2798-
};
2799-
2800-
// Look through `extern` blocks.
2801-
if (auto linkageSpecDecl = dyn_cast<clang::LinkageSpecDecl>(member))
2802-
addDeclsFromContext(linkageSpecDecl);
2803-
2804-
auto namedDecl = dyn_cast<clang::NamedDecl>(member);
2805-
if (!namedDecl)
2786+
auto namedDecl = dyn_cast<clang::NamedDecl>(member);
2787+
if (!namedDecl)
2788+
continue;
2789+
auto name = ctx.getClangModuleLoader()->importName(namedDecl);
2790+
if (!name)
2791+
continue;
2792+
lookupAndAddMembers(name);
2793+
2794+
// Unscoped enums could have their enumerators present
2795+
// in the parent namespace.
2796+
if (auto *ed = dyn_cast<clang::EnumDecl>(member)) {
2797+
if (!ed->isScoped()) {
2798+
for (const auto *ecd : ed->enumerators()) {
2799+
auto name = ctx.getClangModuleLoader()->importName(ecd);
2800+
if (!name)
28062801
continue;
2807-
lookupAndAddMembers(namedDecl);
2808-
2809-
// Unscoped enums could have their enumerators present
2810-
// in the parent namespace.
2811-
if (auto *ed = dyn_cast<clang::EnumDecl>(member)) {
2812-
if (!ed->isScoped()) {
2813-
for (auto *ecd : ed->enumerators()) {
2814-
lookupAndAddMembers(ecd);
2815-
}
2816-
}
2817-
}
2802+
lookupAndAddMembers(name);
28182803
}
2819-
};
2820-
2821-
addDeclsFromContext(redecl);
2804+
}
2805+
}
2806+
}
28222807
}
28232808
}
28242809

lib/ClangImporter/ClangImporter.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5079,11 +5079,6 @@ static bool isDirectLookupMemberContext(const clang::Decl *foundClangDecl,
50795079
return firstDecl->getCanonicalDecl() == parent->getCanonicalDecl();
50805080
}
50815081
}
5082-
// Look through `extern` blocks.
5083-
if (auto linkageSpecDecl = dyn_cast<clang::LinkageSpecDecl>(memberContext)) {
5084-
if (auto parentDecl = dyn_cast<clang::Decl>(linkageSpecDecl->getParent()))
5085-
return isDirectLookupMemberContext(foundClangDecl, parentDecl, parent);
5086-
}
50875082
return false;
50885083
}
50895084

lib/ClangImporter/ImportDecl.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,14 +1156,11 @@ namespace {
11561156
return nullptr;
11571157
// If this is a top-level namespace, don't put it in the module we're
11581158
// importing, put it in the "__ObjC" module that is implicitly imported.
1159-
auto clangDC = decl->getDeclContext();
1160-
while (isa<clang::LinkageSpecDecl>(clangDC))
1161-
clangDC = clangDC->getParent();
1162-
if (!clangDC->isNamespace())
1159+
if (!decl->getParent()->isNamespace())
11631160
dc = Impl.ImportedHeaderUnit;
11641161
else {
11651162
// This is a nested namespace, so just lookup it's parent normally.
1166-
auto parentNS = cast<clang::NamespaceDecl>(clangDC);
1163+
auto parentNS = cast<clang::NamespaceDecl>(decl->getParent());
11671164
auto parent =
11681165
Impl.importDecl(parentNS, getVersion(), /*UseCanonicalDecl*/ false);
11691166
// The parent namespace might not be imported if it's `swift_private`.

lib/ClangImporter/SwiftLookupTable.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,20 +2035,6 @@ void importer::addEntryToLookupTable(SwiftLookupTable &table,
20352035
namedMember = def;
20362036
addEntryToLookupTable(table, namedMember, nameImporter);
20372037
}
2038-
if (auto linkageSpecDecl =
2039-
dyn_cast<clang::LinkageSpecDecl>(canonicalMember)) {
2040-
std::function<void(clang::DeclContext *)> addDeclsFromContext =
2041-
[&](clang::DeclContext *declContext) {
2042-
for (auto nestedDecl : declContext->decls()) {
2043-
if (auto namedMember = dyn_cast<clang::NamedDecl>(nestedDecl))
2044-
addEntryToLookupTable(table, namedMember, nameImporter);
2045-
else if (auto nestedLinkageSpecDecl =
2046-
dyn_cast<clang::LinkageSpecDecl>(nestedDecl))
2047-
addDeclsFromContext(nestedLinkageSpecDecl);
2048-
}
2049-
};
2050-
addDeclsFromContext(linkageSpecDecl);
2051-
}
20522038
}
20532039
}
20542040
if (auto usingDecl = dyn_cast<clang::UsingDecl>(named)) {

test/Interop/Cxx/namespace/Inputs/extern-within-namespace.h

Lines changed: 0 additions & 28 deletions
This file was deleted.

test/Interop/Cxx/namespace/Inputs/module.modulemap

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ module ClassesSecondHeader {
1212
requires cplusplus
1313
}
1414

15-
module ExternWithinNamespace {
16-
header "extern-within-namespace.h"
17-
export *
18-
requires cplusplus
19-
}
20-
2115
module FreeFunctions {
2216
header "free-functions.h"
2317
requires cplusplus

test/Interop/Cxx/namespace/extern-within-namespace-module-interface.swift

Lines changed: 0 additions & 17 deletions
This file was deleted.

test/Interop/Cxx/namespace/extern-within-namespace.swift

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)