Skip to content
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: 4 additions & 0 deletions lib/AST/ASTPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2737,6 +2737,10 @@ static void addNamespaceMembers(Decl *decl,
declOwner = declOwner->getTopLevelModule();
auto Redecls = llvm::SmallVector<clang::NamespaceDecl *, 2>(namespaceDecl->redecls());
std::stable_sort(Redecls.begin(), Redecls.end(), [&](clang::NamespaceDecl *LHS, clang::NamespaceDecl *RHS) {
// A namespace redeclaration will not have an owning Clang module if it is
// declared in a bridging header.
if (!LHS->getOwningModule() || !RHS->getOwningModule())
return (bool)LHS->getOwningModule() < (bool)RHS->getOwningModule();
return LHS->getOwningModule()->Name < RHS->getOwningModule()->Name;
});
for (auto redecl : Redecls) {
Expand Down
15 changes: 15 additions & 0 deletions test/Interop/Cxx/namespace/Inputs/bridging-header.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace NS1 {
namespace NS2 {

struct InBridgingHeader1 {};

} // namespace NS2
} // namespace NS1

namespace NS1 {
namespace NS2 {

struct InBridgingHeader2 {};

} // namespace NS2
} // namespace NS1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// RUN: %target-swift-ide-test -print-header -header-to-print %S/Inputs/bridging-header.h -import-objc-header %S/Inputs/bridging-header.h -source-filename=%s -cxx-interoperability-mode=upcoming-swift | %FileCheck %s

// CHECK: struct InBridgingHeader1
// CHECK: struct InBridgingHeader2