Skip to content
Open
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
14 changes: 14 additions & 0 deletions lib/ClangImporter/ClangImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7818,6 +7818,20 @@ ClangImporter::getCXXFunctionTemplateSpecialization(SubstitutionMap subst,
if (!inserted)
return ConcreteDeclRef(fnIt->second);

// Before we proceed to import the newly instantiated C++ function, make sure
// it gets a unique name in Swift. In particular, it must have a different
// name from all the other instantiations of the same function template, to
// prevent Swift from incorrectly deduplicating the multiple instantiations,
// which would cause a silent miscompile. The naming itself is not important,
// since this will only get called from synthesized code. Let's use the
// mangled Clang name of this instantiation as the swift_name.
std::string mangledNewFn;
llvm::raw_string_ostream mangleRawStream(mangledNewFn);
mangleRawStream << "__swift_specializedThunk_";
getMangledName(mangleRawStream, newFn);
newFn->addAttr(clang::SwiftNameAttr::CreateImplicit(newFn->getASTContext(),
mangledNewFn));

auto *newDecl = cast_or_null<ValueDecl>(
decl->getASTContext().getClangModuleLoader()->importDeclDirectly(newFn));
if (!newDecl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,46 +189,46 @@ func testtFreeFunctionsTemplated(frt : FRTStruct, nonFrt: NonFRTStruct) {
let frtLocalVar1 : Int = 1;

let frtLocalVar2 = global_templated_function_returning_FRT(frtLocalVar1)
// CHECK: function_ref @$sSo39global_templated_function_returning_FRTySo9FRTStructVSiFTo : $@convention(c) (Int) -> FRTStruct
// CHECK: function_ref @$sSo84__swift_specializedThunk__Z39global_templated_function_returning_FRTIlEP9FRTStructT_ySo0J0VSiFTo : $@convention(c) (Int) -> FRTStruct

let frtLocalVar3 = global_templated_function_returning_FRT_copy(frtLocalVar1)
// CHECK: function_ref @$sSo44global_templated_function_returning_FRT_copyySo9FRTStructVSiFTo : $@convention(c) (Int) -> @owned FRTStruct
// CHECK: function_ref @$sSo89__swift_specializedThunk__Z44global_templated_function_returning_FRT_copyIlEP9FRTStructT_ySo0L0VSiFTo : $@convention(c) (Int) -> @owned FRTStruct

let frtLocalVar4 = global_templated_function_returning_FRT_create(frtLocalVar1)
// CHECK: function_ref @$sSo46global_templated_function_returning_FRT_createySo9FRTStructVSiFTo : $@convention(c) (Int) -> @owned FRTStruct
// CHECK: function_ref @$sSo91__swift_specializedThunk__Z46global_templated_function_returning_FRT_createIlEP9FRTStructT_ySo0L0VSiFTo : $@convention(c) (Int) -> @owned FRTStruct

let frtLocalVar5 = global_templated_function_returning_FRT_init(frtLocalVar1)
// CHECK: function_ref @$sSo44global_templated_function_returning_FRT_initySo9FRTStructVSiFTo : $@convention(c) (Int) -> FRTStruct
// CHECK: function_ref @$sSo89__swift_specializedThunk__Z44global_templated_function_returning_FRT_initIlEP9FRTStructT_ySo0L0VSiFTo : $@convention(c) (Int) -> FRTStruct

let frtLocalVar6 = global_templated_function_returning_FRT_clone(frtLocalVar1)
// CHECK: function_ref @$sSo45global_templated_function_returning_FRT_cloneySo9FRTStructVSiFTo : $@convention(c) (Int) -> FRTStruct
// CHECK: function_ref @$sSo90__swift_specializedThunk__Z45global_templated_function_returning_FRT_cloneIlEP9FRTStructT_ySo0L0VSiFTo : $@convention(c) (Int) -> FRTStruct

let frtLocalVar7 = global_templated_function_returning_FRT_with_attr_returns_retained(frtLocalVar1)
// CHECK: function_ref @$sSo66global_templated_function_returning_FRT_with_attr_returns_retainedySo9FRTStructVSiFTo : $@convention(c) (Int) -> @owned FRTStruct
// CHECK: function_ref @$sSo111__swift_specializedThunk__Z66global_templated_function_returning_FRT_with_attr_returns_retainedIlEP9FRTStructT_ySo0O0VSiFTo : $@convention(c) (Int) -> @owned FRTStruct

let frtLocalVar8 = global_templated_function_returning_FRT_copy_with_attr_returns_retained(frtLocalVar1)
// CHECK: function_ref @$sSo71global_templated_function_returning_FRT_copy_with_attr_returns_retainedySo9FRTStructVSiFTo : $@convention(c) (Int) -> @owned FRTStruct
// CHECK: function_ref @$sSo116__swift_specializedThunk__Z71global_templated_function_returning_FRT_copy_with_attr_returns_retainedIlEP9FRTStructT_ySo0P0VSiFTo : $@convention(c) (Int) -> @owned FRTStruct

let frtLocalVar9 = global_templated_function_returning_FRT_create_with_attr_returns_retained(frtLocalVar1)
// CHECK: function_ref @$sSo73global_templated_function_returning_FRT_create_with_attr_returns_retainedySo9FRTStructVSiFTo : $@convention(c) (Int) -> @owned FRTStruct
// CHECK: function_ref @$sSo118__swift_specializedThunk__Z73global_templated_function_returning_FRT_create_with_attr_returns_retainedIlEP9FRTStructT_ySo0P0VSiFTo : $@convention(c) (Int) -> @owned FRTStruct

let frtLocalVar10 = global_templated_function_returning_FRT_with_attr_returns_unretained(frtLocalVar1)
// CHECK: function_ref @$sSo68global_templated_function_returning_FRT_with_attr_returns_unretainedySo9FRTStructVSiFTo : $@convention(c) (Int) -> FRTStruct
// CHECK: function_ref @$sSo113__swift_specializedThunk__Z68global_templated_function_returning_FRT_with_attr_returns_unretainedIlEP9FRTStructT_ySo0O0VSiFTo : $@convention(c) (Int) -> FRTStruct

let frtLocalVar11 = global_templated_function_returning_FRT_copy_with_attr_returns_unretained(frtLocalVar1)
// CHECK: function_ref @$sSo73global_templated_function_returning_FRT_copy_with_attr_returns_unretainedySo9FRTStructVSiFTo : $@convention(c) (Int) -> FRTStruct
// CHECK: function_ref @$sSo118__swift_specializedThunk__Z73global_templated_function_returning_FRT_copy_with_attr_returns_unretainedIlEP9FRTStructT_ySo0P0VSiFTo : $@convention(c) (Int) -> FRTStruct

let frtLocalVar12 = global_templated_function_returning_FRT_create_with_attr_returns_unretained(frtLocalVar1)
// CHECK: function_ref @$sSo75global_templated_function_returning_FRT_create_with_attr_returns_unretainedySo9FRTStructVSiFTo : $@convention(c) (Int) -> FRTStruct
// CHECK: function_ref @$sSo120__swift_specializedThunk__Z75global_templated_function_returning_FRT_create_with_attr_returns_unretainedIlEP9FRTStructT_ySo0P0VSiFTo : $@convention(c) (Int) -> FRTStruct

let frtLocalVar13 = global_function_returning_templated_retrun_frt(frt)
// CHECK: function_ref @$sSo46global_function_returning_templated_retrun_frtySo9FRTStructVACFTo : $@convention(c) (FRTStruct) -> FRTStruct
// CHECK: function_ref @$sSo93__swift_specializedThunk__Z46global_function_returning_templated_retrun_frtIP9FRTStructET_S2_ySo0K0VACFTo : $@convention(c) (FRTStruct) -> FRTStruct

let frtLocalVar14 = global_function_returning_templated_retrun_frt_owned(frt)
// CHECK: function_ref @$sSo52global_function_returning_templated_retrun_frt_ownedySo9FRTStructVACFTo : $@convention(c) (FRTStruct) -> @owned FRTStruct
// CHECK: function_ref @$sSo99__swift_specializedThunk__Z52global_function_returning_templated_retrun_frt_ownedIP9FRTStructET_S2_ySo0L0VACFTo : $@convention(c) (FRTStruct) -> @owned FRTStruct

let nonFrtLocalVar1 = global_function_returning_templated_retrun_frt_owned(nonFrt)
// CHECK: function_ref @$sSo52global_function_returning_templated_retrun_frt_ownedySo12NonFRTStructVACFTo : $@convention(c) (NonFRTStruct) -> NonFRTStruct
// CHECK: function_ref @$sSo102__swift_specializedThunk__Z52global_function_returning_templated_retrun_frt_ownedI12NonFRTStructET_S1_ySo0lM0VACFTo : $@convention(c) (NonFRTStruct) -> NonFRTStruct
}

func testVirtualMethods(base: Base, derived: Derived) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,19 @@ struct Struct {
};

template <typename T>
void templateTypeParamNotUsedInSignature() {}
struct is_bool {
constexpr static bool value = false;
};

template <>
struct is_bool<bool> {
constexpr static bool value = true;
};

template <typename T>
bool templateTypeParamNotUsedInSignature() {
return is_bool<T>::value;
}

template <typename T, typename U>
void multiTemplateTypeParamNotUsedInSignature() {}
Expand Down
8 changes: 4 additions & 4 deletions test/Interop/Cxx/templates/function-template-silgen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import FunctionTemplates
// CHECK: bb0(%0 : $Int32):
// CHECK: [[IL_ZERO:%.*]] = integer_literal $Builtin.Int32, 0
// CHECK: [[ZERO:%.*]] = struct $Int32 ([[IL_ZERO]] : $Builtin.Int32)
// CHECK: [[PASS_THROUGH_CONST_FN:%.*]] = function_ref @$sSo16passThroughConstys5Int32VACFTo : $@convention(c) (Int32) -> Int32
// CHECK: [[PASS_THROUGH_CONST_FN:%.*]] = function_ref @$sSo54__swift_specializedThunk__Z16passThroughConstIiEKT_S0_ys5Int32VACFTo : $@convention(c) (Int32) -> Int32
// CHECK: [[A:%.*]] = apply [[PASS_THROUGH_CONST_FN]]([[ZERO]]) : $@convention(c) (Int32) -> Int32

// CHECK: [[PASS_THROUGH_FN:%.*]] = function_ref @$sSo11passThroughys5Int32VACFTo : $@convention(c) (Int32) -> Int32
// CHECK: [[PASS_THROUGH_FN:%.*]] = function_ref @$sSo48__swift_specializedThunk__Z11passThroughIiET_S0_ys5Int32VACFTo : $@convention(c) (Int32) -> Int32
// CHECK: [[B:%.*]] = apply [[PASS_THROUGH_FN]](%0) : $@convention(c) (Int32) -> Int32

// CHECK: [[ADD_TWO_FN:%.*]] = function_ref @$sSo18addMixedTypeParamsys5Int32VAC_ACtFTo : $@convention(c) (Int32, Int32) -> Int32
// CHECK: [[ADD_TWO_FN:%.*]] = function_ref @$sSo59__swift_specializedThunk__Z18addMixedTypeParamsIiiET_S0_T0_ys5Int32VAC_ACtFTo : $@convention(c) (Int32, Int32) -> Int32
// CHECK: [[C:%.*]] = apply [[ADD_TWO_FN]]([[A]], [[B]]) : $@convention(c) (Int32, Int32) -> Int32

// CHECK: [[ADD_FN:%.*]] = function_ref @$sSo17addSameTypeParamsys5Int32VAC_ACtFTo : $@convention(c) (Int32, Int32) -> Int32
// CHECK: [[ADD_FN:%.*]] = function_ref @$sSo054__swift_specializedThunk__Z17addSameTypeParamsIiET_S0_J1_ys5Int32VAC_ACtFTo : $@convention(c) (Int32, Int32) -> Int32
// CHECK: [[OUT:%.*]] = apply [[ADD_FN]]([[B]], [[C_32:%.*]]) : $@convention(c) (Int32, Int32) -> Int32
// CHECK: return [[OUT]] : $Int32

Expand Down
30 changes: 15 additions & 15 deletions test/Interop/Cxx/templates/member-templates-silgen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import MemberTemplates

// CHECK-LABEL: sil hidden @$s4main9basicTestyyF : $@convention(thin) () -> ()

// CHECK: [[ADD:%.*]] = function_ref @$sSo18HasMemberTemplatesV17addSameTypeParamsys5Int32VAE_AEtFTo : $@convention(cxx_method) (Int32, Int32, @inout HasMemberTemplates) -> Int32
// CHECK: [[ADD:%.*]] = function_ref @$sSo18HasMemberTemplatesV030__swift_specializedThunk__ZN18ab37Templates17addSameTypeParamsIiEET_S1_N1_ys5Int32VAE_AEtFTo : $@convention(cxx_method) (Int32, Int32, @inout HasMemberTemplates) -> Int32
// CHECK: apply [[ADD]]({{.*}}) : $@convention(cxx_method) (Int32, Int32, @inout HasMemberTemplates) -> Int32

// CHECK: [[ADD_TWO_TEMPLATES:%.*]] = function_ref @$sSo18HasMemberTemplatesV18addMixedTypeParamsys5Int32VAE_AEtFTo : $@convention(cxx_method) (Int32, Int32, @inout HasMemberTemplates) -> Int32
// CHECK: [[ADD_TWO_TEMPLATES:%.*]] = function_ref @$sSo18HasMemberTemplatesV030__swift_specializedThunk__ZN18aB42Templates18addMixedTypeParamsIiiEET_S1_T0_ys5Int32VAE_AEtFTo : $@convention(cxx_method) (Int32, Int32, @inout HasMemberTemplates) -> Int32
// CHECK: apply [[ADD_TWO_TEMPLATES]]({{.*}}) : $@convention(cxx_method) (Int32, Int32, @inout HasMemberTemplates) -> Int32

// CHECK: [[ADD_ALL:%.*]] = function_ref @$sSo18HasMemberTemplatesV6addAllys5Int32VAE_A2EtFTo : $@convention(cxx_method) (Int32, Int32, Int32, @inout HasMemberTemplates) -> Int32
// CHECK: [[ADD_ALL:%.*]] = function_ref @$sSo18HasMemberTemplatesV030__swift_specializedThunk__ZN18aB28Templates6addAllIiiEEiiT_T0_ys5Int32VAE_A2EtFTo : $@convention(cxx_method) (Int32, Int32, Int32, @inout HasMemberTemplates) -> Int32
// CHECK: apply [[ADD_ALL]]({{.*}}) : $@convention(cxx_method) (Int32, Int32, Int32, @inout HasMemberTemplates) -> Int32

// CHECK: [[DO_NOTHING:%.*]] = function_ref @$sSo18HasMemberTemplatesV17doNothingConstRefyys5Int32VFTo : $@convention(cxx_method) (@in_guaranteed Int32, @inout HasMemberTemplates) -> ()
// CHECK: [[DO_NOTHING:%.*]] = function_ref @$sSo18HasMemberTemplatesV030__swift_specializedThunk__ZN18aB37Templates17doNothingConstRefIiEEvRKT_yys5Int32VFTo : $@convention(cxx_method) (@in_guaranteed Int32, @inout HasMemberTemplates) -> ()
// CHECK: apply [[DO_NOTHING]]({{.*}}) : $@convention(cxx_method) (@in_guaranteed Int32, @inout HasMemberTemplates) -> ()

// CHECK-LABEL: end sil function '$s4main9basicTestyyF'
Expand All @@ -26,17 +26,17 @@ func basicTest() {
obj.doNothingConstRef(i)
}

// CHECK-LABEL: sil [asmname "{{.*}}addSameTypeParams{{.*}}"] [clang HasMemberTemplates.addSameTypeParams] @$sSo18HasMemberTemplatesV17addSameTypeParamsys5Int32VAE_AEtFTo : $@convention(cxx_method) (Int32, Int32, @inout HasMemberTemplates) -> Int32
// CHECK-LABEL: sil [asmname "{{.*}}addSameTypeParams{{.*}}"] [clang HasMemberTemplates.__swift_specializedThunk__ZN18HasMemberTemplates17addSameTypeParamsIiEET_S1_S1_] @$sSo18HasMemberTemplatesV030__swift_specializedThunk__ZN18ab37Templates17addSameTypeParamsIiEET_S1_N1_ys5Int32VAE_AEtFTo : $@convention(cxx_method) (Int32, Int32, @inout HasMemberTemplates) -> Int32

// CHECK-LABEL: sil [asmname "{{.*}}addMixedTypeParams{{.*}}"] [clang HasMemberTemplates.addMixedTypeParams] @$sSo18HasMemberTemplatesV18addMixedTypeParamsys5Int32VAE_AEtFTo : $@convention(cxx_method) (Int32, Int32, @inout HasMemberTemplates) -> Int32
// CHECK-LABEL: sil [asmname "{{.*}}addMixedTypeParams{{.*}}"] [clang HasMemberTemplates.__swift_specializedThunk__ZN18HasMemberTemplates18addMixedTypeParamsIiiEET_S1_T0_] @$sSo18HasMemberTemplatesV030__swift_specializedThunk__ZN18aB42Templates18addMixedTypeParamsIiiEET_S1_T0_ys5Int32VAE_AEtFTo : $@convention(cxx_method) (Int32, Int32, @inout HasMemberTemplates) -> Int32

// CHECK-LABEL: sil [asmname "{{.*}}addAll{{.*}}"] [clang HasMemberTemplates.addAll] @$sSo18HasMemberTemplatesV6addAllys5Int32VAE_A2EtFTo : $@convention(cxx_method) (Int32, Int32, Int32, @inout HasMemberTemplates) -> Int32
// CHECK-LABEL: sil [asmname "{{.*}}addAll{{.*}}"] [clang HasMemberTemplates.__swift_specializedThunk__ZN18HasMemberTemplates6addAllIiiEEiiT_T0_] @$sSo18HasMemberTemplatesV030__swift_specializedThunk__ZN18aB28Templates6addAllIiiEEiiT_T0_ys5Int32VAE_A2EtFTo : $@convention(cxx_method) (Int32, Int32, Int32, @inout HasMemberTemplates) -> Int32

// CHECK-LABEL: sil [asmname "{{.*}}doNothingConstRef{{.*}}"] [clang HasMemberTemplates.doNothingConstRef] @$sSo18HasMemberTemplatesV17doNothingConstRefyys5Int32VFTo : $@convention(cxx_method) (@in_guaranteed Int32, @inout HasMemberTemplates) -> ()
// CHECK-LABEL: sil [asmname "{{.*}}doNothingConstRef{{.*}}"] [clang HasMemberTemplates.__swift_specializedThunk__ZN18HasMemberTemplates17doNothingConstRefIiEEvRKT_] @$sSo18HasMemberTemplatesV030__swift_specializedThunk__ZN18aB37Templates17doNothingConstRefIiEEvRKT_yys5Int32VFTo : $@convention(cxx_method) (@in_guaranteed Int32, @inout HasMemberTemplates) -> ()

// CHECK-LABEL: sil hidden @$s4main12testSetValueyyF : $@convention(thin) () -> ()

// CHECK: [[SET_VALUE:%.*]] = function_ref @$sSo0044TemplateClassWithMemberTemplatesCInt_CeCInkcV8setValueyySiFTo : $@convention(cxx_method) (Int, @inout TemplateClassWithMemberTemplates<CInt>) -> ()
// CHECK: [[SET_VALUE:%.*]] = function_ref @$sSo0044TemplateClassWithMemberTemplatesCInt_CeCInkcV81__swift_specializedThunk__ZN32TemplateClassWithMemberTemplatesIiE8setValueIlEEvT_yySiFTo : $@convention(cxx_method) (Int, @inout TemplateClassWithMemberTemplates<CInt>) -> ()
// CHECK: apply [[SET_VALUE]]({{.*}}) : $@convention(cxx_method) (Int, @inout TemplateClassWithMemberTemplates<CInt>) -> ()

// CHECK-LABEL: end sil function '$s4main12testSetValueyyF'
Expand All @@ -47,13 +47,13 @@ func testSetValue() {

// CHECK-LABEL: sil hidden @$s4main17testStaticMembersyyF : $@convention(thin) () -> ()

// CHECK: [[ADD_FN:%.*]] = function_ref @$sSo24HasStaticMemberTemplatesV3addyS2i_SitFZTo : $@convention(c) (Int, Int) -> Int
// CHECK: [[ADD_FN:%.*]] = function_ref @$sSo24HasStaticMemberTemplatesV030__swift_specializedThunk__ZN24abc22Templates3addIlEET_S1_L1_yS2i_SitFZTo : $@convention(c) (Int, Int) -> Int
// CHECK: apply [[ADD_FN]]({{.*}}) : $@convention(c) (Int, Int) -> Int

// CHECK: [[ADD_TWO_TEMPLATES_FN:%.*]] = function_ref @$sSo24HasStaticMemberTemplatesV06addTwoD0yS2i_s4Int8VtFZTo : $@convention(c) (Int, Int8) -> Int
// CHECK: [[ADD_TWO_TEMPLATES_FN:%.*]] = function_ref @$sSo24HasStaticMemberTemplatesV030__swift_specializedThunk__ZN24abc17Templates15addTwoD13IlcEET_S1_T0_yS2i_s4Int8VtFZTo : $@convention(c) (Int, Int8) -> Int
// CHECK: apply [[ADD_TWO_TEMPLATES_FN]]({{.*}}) : $@convention(c) (Int, Int8) -> Int

// CHECK: [[REMOVE_REFERENCE_FN:%.*]] = function_ref @$sSo24HasStaticMemberTemplatesV15removeReferenceyS2izFZTo : $@convention(c) (@inout Int) -> Int
// CHECK: [[REMOVE_REFERENCE_FN:%.*]] = function_ref @$sSo24HasStaticMemberTemplatesV030__swift_specializedThunk__ZN24abC36Templates15removeReferenceIlEET_RS1_yS2izFZTo : $@convention(c) (@inout Int) -> Int
// CHECK: apply [[REMOVE_REFERENCE_FN]]({{.*}}) : $@convention(c) (@inout Int) -> Int

// CHECK-LABEL: end sil function '$s4main17testStaticMembersyyF'
Expand All @@ -65,8 +65,8 @@ func testStaticMembers() {
HasStaticMemberTemplates.removeReference(&x)
}

// CHECK: sil hidden_external [asmname "{{.*}}add{{.*}}"] [clang HasStaticMemberTemplates.add] @$sSo24HasStaticMemberTemplatesV3addyS2i_SitFZTo : $@convention(c) (Int, Int) -> Int
// CHECK: sil hidden_external [asmname "{{.*}}add{{.*}}"] [clang HasStaticMemberTemplates.__swift_specializedThunk__ZN24HasStaticMemberTemplates3addIlEET_S1_S1_] @$sSo24HasStaticMemberTemplatesV030__swift_specializedThunk__ZN24abc22Templates3addIlEET_S1_L1_yS2i_SitFZTo : $@convention(c) (Int, Int) -> Int

// CHECK: sil hidden_external [asmname "{{.*}}addTwoTemplates{{.*}}"] [clang HasStaticMemberTemplates.addTwoTemplates] @$sSo24HasStaticMemberTemplatesV06addTwoD0yS2i_s4Int8VtFZTo : $@convention(c) (Int, Int8) -> Int
// CHECK: sil hidden_external [asmname "{{.*}}addTwoTemplates{{.*}}"] [clang HasStaticMemberTemplates.__swift_specializedThunk__ZN24HasStaticMemberTemplates15addTwoTemplatesIlcEET_S1_T0_] @$sSo24HasStaticMemberTemplatesV030__swift_specializedThunk__ZN24abc17Templates15addTwoD13IlcEET_S1_T0_yS2i_s4Int8VtFZTo : $@convention(c) (Int, Int8) -> Int

// CHECK: sil hidden_external [asmname "{{.*}}removeReference{{.*}}"] [clang HasStaticMemberTemplates.removeReference] @$sSo24HasStaticMemberTemplatesV15removeReferenceyS2izFZTo : $@convention(c) (@inout Int) -> Int
// CHECK: sil hidden_external [asmname "{{.*}}removeReference{{.*}}"] [clang HasStaticMemberTemplates.__swift_specializedThunk__ZN24HasStaticMemberTemplates15removeReferenceIlEET_RS1_] @$sSo24HasStaticMemberTemplatesV030__swift_specializedThunk__ZN24abC36Templates15removeReferenceIlEET_RS1_yS2izFZTo : $@convention(c) (@inout Int) -> Int
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// RUN: %target-swift-emit-silgen %s -cxx-interoperability-mode=default -I %S/Inputs | %FileCheck %s

import TemplateTypeParameterNotInSignature

_ = templateTypeParamNotUsedInSignature(T: Int.self)
_ = templateTypeParamNotUsedInSignature(T: Bool.self)


// CHECK: sil [transparent] [serialized] [ossa] @$sSC35templateTypeParamNotUsedInSignatureySbSimF : $@convention(thin) (@thin Int.Type) -> Bool {
// CHECK: bb0(%0 : $@thin Int.Type):
// CHECK: {{.*}} = function_ref @$sSo69__swift_specializedThunk__Z35templateTypeParamNotUsedInSignatureIlEbvSbyFTo : $@convention(c) () -> Bool
// CHECK: } // end sil function '$sSC35templateTypeParamNotUsedInSignatureySbSimF'

// CHECK: sil [transparent] [serialized] [ossa] @$sSC35templateTypeParamNotUsedInSignatureyS2bmF : $@convention(thin) (@thin Bool.Type) -> Bool {
// CHECK: bb0(%0 : $@thin Bool.Type):
// CHECK: {{.*}} = function_ref @$sSo69__swift_specializedThunk__Z35templateTypeParamNotUsedInSignatureIbEbvSbyFTo : $@convention(c) () -> Bool
// CHECK: } // end sil function '$sSC35templateTypeParamNotUsedInSignatureyS2bmF'
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ TemplateNotInSignatureTestSuite.test("Function with defaulted template type para

TemplateNotInSignatureTestSuite.test("Instantiate the same function template twice.") {
// Intentionally test the same thing twice.
templateTypeParamNotUsedInSignature(T: Int.self)
templateTypeParamNotUsedInSignature(T: Int.self)
let res1 = templateTypeParamNotUsedInSignature(T: Int.self)
expectFalse(res1)
let res2 = templateTypeParamNotUsedInSignature(T: Int.self)
expectFalse(res2)
let res3 = templateTypeParamNotUsedInSignature(T: Bool.self)
expectTrue(res3)
}

TemplateNotInSignatureTestSuite.test("Pointer types") {
Expand Down