diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp --- a/clang/lib/CodeGen/CGObjC.cpp +++ b/clang/lib/CodeGen/CGObjC.cpp @@ -981,7 +981,7 @@ generateObjCGetterBody(IMP, PID, OMD, AtomicHelperFn); - FinishFunction(); + FinishFunction(OMD->getEndLoc()); } static bool hasTrivialGetExpr(const ObjCPropertyImplDecl *propImpl) { @@ -1515,7 +1515,7 @@ generateObjCSetterBody(IMP, PID, AtomicHelperFn); - FinishFunction(); + FinishFunction(OMD->getEndLoc()); } namespace { diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -6189,7 +6189,7 @@ // Emit the finalizer body: // (* %0) RCG.emitCleanups(CGF, N, PrivateAddr); - CGF.FinishFunction(); + CGF.FinishFunction(Loc); return Fn; } diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -377,9 +377,12 @@ if (HasCleanups) { // Make sure the line table doesn't jump back into the body for // the ret after it's been at EndLoc. - if (CGDebugInfo *DI = getDebugInfo()) + if (CGDebugInfo *DI = getDebugInfo()) { if (OnlySimpleReturnStmts) DI->EmitLocation(Builder, EndLoc); + else + assert(EndLoc.isValid() && "no location for inlineable cleanup calls"); + } PopCleanupBlocks(PrologueCleanupDepth); } diff --git a/clang/test/CodeGenObjCXX/synthesized-property-cleanup.mm b/clang/test/CodeGenObjCXX/synthesized-property-cleanup.mm new file mode 100644 --- /dev/null +++ b/clang/test/CodeGenObjCXX/synthesized-property-cleanup.mm @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 -triple arm64e-apple-ios13.0 -debug-info-kind=standalone -fobjc-arc \ +// RUN: %s -emit-llvm -o - | FileCheck %s + +@interface NSObject ++ (id)alloc; +@end + +@interface NSString : NSObject +@end + +// CHECK: define {{.*}}@"\01-[MyData setData:]" +// CHECK: [[DATA:%.*]] = alloca %struct.Data +// CHECK: call %struct.Data* @_ZN4DataD1Ev(%struct.Data* [[DATA]]){{.*}}, !dbg [[LOC:![0-9]+]] +// CHECK-NEXT: ret void + +// [[LOC]] = !DILocation(line: 0 + +@interface MyData : NSObject +struct Data { + NSString *name; +}; +@property struct Data data; +@end +@implementation MyData +@end