@@ -1948,13 +1948,21 @@ CodeGenFunction::GenerateCopyHelperFunction(const CGBlockInfo &blockInfo) {
1948
1948
if (CGM.supportsCOMDAT ())
1949
1949
Fn->setComdat (CGM.getModule ().getOrInsertComdat (FuncName));
1950
1950
1951
+ IdentifierInfo *II = &C.Idents .get (FuncName);
1952
+
1951
1953
SmallVector<QualType, 2 > ArgTys;
1952
1954
ArgTys.push_back (C.VoidPtrTy );
1953
1955
ArgTys.push_back (C.VoidPtrTy );
1956
+ QualType FunctionTy = C.getFunctionType (ReturnTy, ArgTys, {});
1954
1957
1958
+ FunctionDecl *FD = FunctionDecl::Create (
1959
+ C, C.getTranslationUnitDecl (), SourceLocation (), SourceLocation (), II,
1960
+ FunctionTy, nullptr , SC_Static, false , false );
1955
1961
setBlockHelperAttributesVisibility (blockInfo.CapturesNonExternalType , Fn, FI,
1956
1962
CGM);
1957
- StartFunction (GlobalDecl (), ReturnTy, Fn, FI, args);
1963
+ // This is necessary to avoid inheriting the previous line number.
1964
+ FD->setImplicit ();
1965
+ StartFunction (FD, ReturnTy, Fn, FI, args);
1958
1966
auto AL = ApplyDebugLocation::CreateArtificial (*this );
1959
1967
1960
1968
llvm::Type *structPtrTy = blockInfo.StructureType ->getPointerTo ();
@@ -2135,12 +2143,21 @@ CodeGenFunction::GenerateDestroyHelperFunction(const CGBlockInfo &blockInfo) {
2135
2143
if (CGM.supportsCOMDAT ())
2136
2144
Fn->setComdat (CGM.getModule ().getOrInsertComdat (FuncName));
2137
2145
2146
+ IdentifierInfo *II = &C.Idents .get (FuncName);
2147
+
2138
2148
SmallVector<QualType, 1 > ArgTys;
2139
2149
ArgTys.push_back (C.VoidPtrTy );
2150
+ QualType FunctionTy = C.getFunctionType (ReturnTy, ArgTys, {});
2151
+
2152
+ FunctionDecl *FD = FunctionDecl::Create (
2153
+ C, C.getTranslationUnitDecl (), SourceLocation (), SourceLocation (), II,
2154
+ FunctionTy, nullptr , SC_Static, false , false );
2140
2155
2141
2156
setBlockHelperAttributesVisibility (blockInfo.CapturesNonExternalType , Fn, FI,
2142
2157
CGM);
2143
- StartFunction (GlobalDecl (), ReturnTy, Fn, FI, args);
2158
+ // This is necessary to avoid inheriting the previous line number.
2159
+ FD->setImplicit ();
2160
+ StartFunction (FD, ReturnTy, Fn, FI, args);
2144
2161
markAsIgnoreThreadCheckingAtRuntime (Fn);
2145
2162
2146
2163
auto AL = ApplyDebugLocation::CreateArtificial (*this );
@@ -2378,13 +2395,21 @@ generateByrefCopyHelper(CodeGenFunction &CGF, const BlockByrefInfo &byrefInfo,
2378
2395
llvm::Function::Create (LTy, llvm::GlobalValue::InternalLinkage,
2379
2396
" __Block_byref_object_copy_" , &CGF.CGM .getModule ());
2380
2397
2398
+ IdentifierInfo *II
2399
+ = &Context.Idents .get (" __Block_byref_object_copy_" );
2400
+
2381
2401
SmallVector<QualType, 2 > ArgTys;
2382
2402
ArgTys.push_back (Context.VoidPtrTy );
2383
2403
ArgTys.push_back (Context.VoidPtrTy );
2404
+ QualType FunctionTy = Context.getFunctionType (ReturnTy, ArgTys, {});
2405
+
2406
+ FunctionDecl *FD = FunctionDecl::Create (
2407
+ Context, Context.getTranslationUnitDecl (), SourceLocation (),
2408
+ SourceLocation (), II, FunctionTy, nullptr , SC_Static, false , false );
2384
2409
2385
2410
CGF.CGM .SetInternalFunctionAttributes (GlobalDecl (), Fn, FI);
2386
2411
2387
- CGF.StartFunction (GlobalDecl () , ReturnTy, Fn, FI, args);
2412
+ CGF.StartFunction (FD , ReturnTy, Fn, FI, args);
2388
2413
2389
2414
if (generator.needsCopy ()) {
2390
2415
llvm::Type *byrefPtrType = byrefInfo.Type ->getPointerTo (0 );
@@ -2446,12 +2471,20 @@ generateByrefDisposeHelper(CodeGenFunction &CGF,
2446
2471
" __Block_byref_object_dispose_" ,
2447
2472
&CGF.CGM .getModule ());
2448
2473
2474
+ IdentifierInfo *II
2475
+ = &Context.Idents .get (" __Block_byref_object_dispose_" );
2476
+
2449
2477
SmallVector<QualType, 1 > ArgTys;
2450
2478
ArgTys.push_back (Context.VoidPtrTy );
2479
+ QualType FunctionTy = Context.getFunctionType (R, ArgTys, {});
2480
+
2481
+ FunctionDecl *FD = FunctionDecl::Create (
2482
+ Context, Context.getTranslationUnitDecl (), SourceLocation (),
2483
+ SourceLocation (), II, FunctionTy, nullptr , SC_Static, false , false );
2451
2484
2452
2485
CGF.CGM .SetInternalFunctionAttributes (GlobalDecl (), Fn, FI);
2453
2486
2454
- CGF.StartFunction (GlobalDecl () , R, Fn, FI, args);
2487
+ CGF.StartFunction (FD , R, Fn, FI, args);
2455
2488
2456
2489
if (generator.needsDispose ()) {
2457
2490
Address addr = CGF.GetAddrOfLocalVar (&Src);
0 commit comments