Skip to content

Commit 6aa9d43

Browse files
authored
Merge pull request #77591 from swiftlang/egorzhdan/class-template-nullptr
[cxx-interop] Disambiguate template instantiations with nullptr parameters
2 parents acb0c5a + 3d80ab3 commit 6aa9d43

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

lib/ClangImporter/ClangClassTemplateNamePrinter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ struct TemplateInstantiationNamePrinter
3838
switch (type->getKind()) {
3939
case clang::BuiltinType::Void:
4040
return "Void";
41+
case clang::BuiltinType::NullPtr:
42+
return "nil";
4143

4244
#define MAP_BUILTIN_TYPE(CLANG_BUILTIN_KIND, SWIFT_TYPE_NAME) \
4345
case clang::BuiltinType::CLANG_BUILTIN_KIND: \

test/Interop/Cxx/templates/Inputs/class-template-with-primitive-argument.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_WITH_PRIMITIVE_ARGUMENT_H
22
#define TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_WITH_PRIMITIVE_ARGUMENT_H
33

4+
#include <cstddef>
5+
46
template<class T>
57
struct MagicWrapper {
68
T t;
@@ -23,6 +25,7 @@ typedef MagicWrapper<int[]> WrappedMagicIntArr;
2325
typedef MagicWrapper<long[]> WrappedMagicLongArr;
2426
typedef MagicWrapper<int[123]> WrappedMagicIntFixedSizeArr1;
2527
typedef MagicWrapper<int[124]> WrappedMagicIntFixedSizeArr2;
28+
typedef MagicWrapper<std::nullptr_t> WrappedMagicNullPtr;
2629

2730
typedef DoubleWrapper<MagicWrapper<int>> DoubleWrappedInt;
2831
typedef DoubleWrapper<MagicWrapper<const int>> DoubleWrappedIntConst;
@@ -33,5 +36,6 @@ typedef DoubleWrapper<MagicWrapper<int[]>> DoubleWrappedMagicIntArr;
3336
typedef DoubleWrapper<MagicWrapper<long[]>> DoubleWrappedMagicLongArr;
3437
typedef DoubleWrapper<MagicWrapper<int[42]>> DoubleWrappedMagicIntFixedSizeArr1;
3538
typedef DoubleWrapper<MagicWrapper<int[43]>> DoubleWrappedMagicIntFixedSizeArr2;
39+
typedef DoubleWrapper<MagicWrapper<std::nullptr_t>> DoubleWrappedMagicNullPtr;
3640

3741
#endif // TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_WITH_PRIMITIVE_ARGUMENT_H

test/Interop/Cxx/templates/class-template-with-primitive-argument-module-interface.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
// CHECK: typealias WrappedMagicLongArr = MagicWrapper<[CLong]>
1818
// CHECK: typealias WrappedMagicIntFixedSizeArr1 = MagicWrapper<Vector<CInt, 123>>
1919
// CHECK: typealias WrappedMagicIntFixedSizeArr2 = MagicWrapper<Vector<CInt, 124>>
20+
// CHECK: typealias WrappedMagicNullPtr = MagicWrapper<nil>
2021

2122
// CHECK: typealias DoubleWrappedInt = DoubleWrapper<MagicWrapper<CInt>>
2223
// CHECK: typealias DoubleWrappedIntConst = DoubleWrapper<MagicWrapper<CInt_const>>
@@ -27,3 +28,4 @@
2728
// CHECK: typealias DoubleWrappedMagicLongArr = DoubleWrapper<MagicWrapper<[CLong]>>
2829
// CHECK: typealias DoubleWrappedMagicIntFixedSizeArr1 = DoubleWrapper<MagicWrapper<Vector<CInt, 42>>>
2930
// CHECK: typealias DoubleWrappedMagicIntFixedSizeArr2 = DoubleWrapper<MagicWrapper<Vector<CInt, 43>>>
31+
// CHECK: typealias DoubleWrappedMagicNullPtr = DoubleWrapper<MagicWrapper<nil>>

0 commit comments

Comments
 (0)