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
6 changes: 6 additions & 0 deletions lib/ClangImporter/ClangClassTemplateNamePrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ struct TemplateInstantiationNamePrinter

return buffer.str().str();
}

std::string VisitVectorType(const clang::VectorType *type) {
return (Twine("SIMD") + std::to_string(type->getNumElements()) + "<" +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think with twine we might no longer need the to_string. But not 100% confident on that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't compile for me if I remove to_string.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, maybe it still needs a ctor like Twine("SIMD") + Twine(type->getNumElements()) + ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think I slightly prefer to_string over Twine(...) in this case, since that makes it explicit that we aren't e.g. constructing a string with a given capacity/size – something a std::string constructor would do 🙂

Visit(type->getElementType().getTypePtr()) + ">")
.str();
}
};

std::string swift::importer::printClassTemplateSpecializationName(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <simd/simd.h>

template <typename T>
struct Templated {
T t;
};

typedef Templated<simd::uint1> TemplatedSIMDUInt1;
typedef Templated<simd::uint16> TemplatedSIMDUInt16;
typedef Templated<simd::float3> TemplatedSIMDFloat3;
typedef Templated<simd::float4> TemplatedSIMDFloat4;
typedef Templated<simd::double8> TemplatedSIMDDouble8;
5 changes: 5 additions & 0 deletions test/Interop/Cxx/templates/Inputs/module.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ module ClassTemplateWithOutOfLineMember {
requires cplusplus
}

module ClassTemplateWithSIMDParameter {
header "class-template-with-simd-parameter.h"
requires cplusplus
}

module NotPreDefinedClassTemplate {
header "not-pre-defined-class-template.h"
requires cplusplus
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// RUN: %target-swift-ide-test -print-module -module-to-print=ClassTemplateWithSIMDParameter -I %S/Inputs -source-filename=x -cxx-interoperability-mode=upcoming-swift | %FileCheck %s

// REQUIRES: OS=macosx || OS=ios

// CHECK: typealias TemplatedSIMDUInt1 = Templated<CUnsignedInt>
// CHECK: typealias TemplatedSIMDUInt16 = Templated<SIMD16<CUnsignedInt>>
// CHECK: typealias TemplatedSIMDFloat3 = Templated<SIMD3<CFloat>>
// CHECK: typealias TemplatedSIMDFloat4 = Templated<SIMD4<CFloat>>
// CHECK: typealias TemplatedSIMDDouble8 = Templated<SIMD8<CDouble>>