File tree Expand file tree Collapse file tree 4 files changed +41
-0
lines changed
test/Interop/Cxx/templates Expand file tree Collapse file tree 4 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -3326,6 +3326,14 @@ namespace {
33263326 continue ;
33273327 }
33283328
3329+ if (auto recordDecl = dyn_cast<clang::RecordDecl>(m)) {
3330+ // An injected class name decl will just point back to the parent
3331+ // decl, so don't import it.
3332+ if (recordDecl->isInjectedClassName ()) {
3333+ continue ;
3334+ }
3335+ }
3336+
33293337 auto nd = dyn_cast<clang::NamedDecl>(m);
33303338 if (!nd) {
33313339 // We couldn't import the member, so we can't reference it in Swift.
@@ -3569,6 +3577,19 @@ namespace {
35693577 return VisitCXXRecordDecl (def);
35703578 }
35713579
3580+ Decl *VisitClassTemplateDecl (const clang::ClassTemplateDecl *decl) {
3581+ // When loading a namespace's sub-decls, we won't add template
3582+ // specilizations, so make sure to do that here.
3583+ for (auto spec : decl->specializations ()) {
3584+ if (auto importedSpec = Impl.importDecl (spec, getVersion ())) {
3585+ if (auto namespaceDecl =
3586+ dyn_cast<EnumDecl>(importedSpec->getDeclContext ()))
3587+ namespaceDecl->addMember (importedSpec);
3588+ }
3589+ }
3590+ return nullptr ;
3591+ }
3592+
35723593 Decl *VisitClassTemplatePartialSpecializationDecl (
35733594 const clang::ClassTemplatePartialSpecializationDecl *decl) {
35743595 // Note: partial template specializations are not imported.
Original file line number Diff line number Diff line change 1+ namespace Space {
2+
3+ template <class ...> struct Ship ;
4+ template <class T , class ... Args> struct Ship <T(Args...)> {};
5+
6+ using Orbiter = Ship<void (bool )>;
7+
8+ } // namespace Space
Original file line number Diff line number Diff line change @@ -57,3 +57,7 @@ module ClassTemplateTemplateParameter {
5757module ClassTemplateWithTypedef {
5858 header "class-template-with-typedef.h"
5959}
60+
61+ module ClassTemplateInNamespace {
62+ header "class-template-in-namespace.h"
63+ }
Original file line number Diff line number Diff line change 1+ // RUN: %target-swift-ide-test -print-module -module-to-print=ClassTemplateInNamespace -I %S/Inputs -source-filename=x -enable-cxx-interop | %FileCheck %s
2+
3+ // CHECK: enum Space {
4+ // CHECK: struct __CxxTemplateInstN5Space4ShipIJFvbEEEE {
5+ // CHECK: init()
6+ // CHECK: }
7+ // CHECK: typealias Orbiter = Space.__CxxTemplateInstN5Space4ShipIJFvbEEEE
8+ // CHECK: }
You can’t perform that action at this time.
0 commit comments