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
9 changes: 8 additions & 1 deletion lib/AST/ASTMangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include "clang/AST/ASTContext.h"
#include "clang/AST/Attr.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/Mangle.h"
Expand Down Expand Up @@ -3079,7 +3080,7 @@ void ASTMangler::appendAnyGenericType(const GenericTypeDecl *decl,

auto *nominal = dyn_cast<NominalTypeDecl>(decl);

if (nominal && isa<BuiltinTupleDecl>(nominal))
if (isa_and_nonnull<BuiltinTupleDecl>(nominal))
return appendOperator("BT");

// Check for certain standard types.
Expand Down Expand Up @@ -3131,6 +3132,12 @@ void ASTMangler::appendAnyGenericType(const GenericTypeDecl *decl,
return false;
}

// Mangle `Foo` from `namespace Bar { class Foo; } using Bar::Foo;` the same
// way as if we spelled `Bar.Foo` explicitly.
if (const auto *usingShadowDecl =
dyn_cast<clang::UsingShadowDecl>(namedDecl))
namedDecl = usingShadowDecl->getTargetDecl();

// Mangle ObjC classes using their runtime names.
auto interface = dyn_cast<clang::ObjCInterfaceDecl>(namedDecl);
auto protocol = dyn_cast<clang::ObjCProtocolDecl>(namedDecl);
Expand Down
5 changes: 5 additions & 0 deletions test/Interop/Cxx/namespace/Inputs/module.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,8 @@ module MembersTransitive {
header "members-transitive.h"
requires cplusplus
}

module UsingFromNamespace {
header "using-from-namespace.h"
requires cplusplus
}
13 changes: 13 additions & 0 deletions test/Interop/Cxx/namespace/Inputs/using-from-namespace.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

namespace Test {
class Foo {};
namespace Test2 {
class Bar {};
} // namespace Test2

using Test2::Bar;
} // namespace Test

using Test::Bar;
using Test::Foo;
6 changes: 6 additions & 0 deletions test/Interop/Cxx/namespace/using-from-namespace.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// RUN: %target-swift-emit-irgen -I %S/Inputs/ -cxx-interoperability-mode=default -g %s

import UsingFromNamespace

func f(_ foo: Foo) {}
func g(_ bar: Bar) {}