Index: clang/lib/CodeGen/CGDebugInfo.h =================================================================== --- clang/lib/CodeGen/CGDebugInfo.h +++ clang/lib/CodeGen/CGDebugInfo.h @@ -749,6 +749,8 @@ Other.CGF = nullptr; } + ApplyDebugLocation &operator=(ApplyDebugLocation &&) = default; + ~ApplyDebugLocation(); /// Apply TemporaryLocation if it is valid. Otherwise switch Index: clang/lib/CodeGen/CodeGenFunction.cpp =================================================================== --- clang/lib/CodeGen/CodeGenFunction.cpp +++ clang/lib/CodeGen/CodeGenFunction.cpp @@ -329,9 +329,15 @@ 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()) + Optional AL; + if (CGDebugInfo *DI = getDebugInfo()) { if (OnlySimpleReturnStmts) DI->EmitLocation(Builder, EndLoc); + else + // We may not have a valid end location. Try to apply it anyway, and + // fall back to an artificial location if needed. + AL = ApplyDebugLocation::CreateDefaultArtificial(*this, EndLoc); + } PopCleanupBlocks(PrologueCleanupDepth); } Index: clang/test/CodeGenObjCXX/property-object-cleanup.mm =================================================================== --- /dev/null +++ clang/test/CodeGenObjCXX/property-object-cleanup.mm @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 -triple arm64e-apple-ios13.4.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