[clang] ce7d359 - Debug Info: Assert that location is available for cleanups

Adrian Prantl via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 5 12:45:30 PST 2019


Author: Adrian Prantl
Date: 2019-12-05T12:45:10-08:00
New Revision: ce7d35988d1ca5e17758283804ea1f76389dc1f0

URL: https://github.com/llvm/llvm-project/commit/ce7d35988d1ca5e17758283804ea1f76389dc1f0
DIFF: https://github.com/llvm/llvm-project/commit/ce7d35988d1ca5e17758283804ea1f76389dc1f0.diff

LOG: Debug Info: Assert that location is available for cleanups

rdar://57630879

Differential Revision: https://reviews.llvm.org/D71042

Added: 
    clang/test/CodeGenObjCXX/synthesized-property-cleanup.mm

Modified: 
    clang/lib/CodeGen/CGObjC.cpp
    clang/lib/CodeGen/CGOpenMPRuntime.cpp
    clang/lib/CodeGen/CodeGenFunction.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index 14391f3b129a..6db05391722d 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/clang/lib/CodeGen/CGObjC.cpp
@@ -981,7 +981,7 @@ void CodeGenFunction::GenerateObjCGetter(ObjCImplementationDecl *IMP,
 
   generateObjCGetterBody(IMP, PID, OMD, AtomicHelperFn);
 
-  FinishFunction();
+  FinishFunction(OMD->getEndLoc());
 }
 
 static bool hasTrivialGetExpr(const ObjCPropertyImplDecl *propImpl) {
@@ -1515,7 +1515,7 @@ void CodeGenFunction::GenerateObjCSetter(ObjCImplementationDecl *IMP,
 
   generateObjCSetterBody(IMP, PID, AtomicHelperFn);
 
-  FinishFunction();
+  FinishFunction(OMD->getEndLoc());
 }
 
 namespace {

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 8ce403c8dab0..9f1b907e89db 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -6189,7 +6189,7 @@ static llvm::Value *emitReduceFiniFunction(CodeGenModule &CGM,
   // Emit the finalizer body:
   // <destroy>(<type>* %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
index fd3020835a4d..a25383f6e158 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -377,9 +377,12 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {
   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
index 000000000000..805766b23bdb
--- /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
+
+ at interface NSObject
++ (id)alloc;
+ at end
+
+ at interface NSString : NSObject
+ at 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
+
+ at interface MyData : NSObject
+struct Data {
+    NSString *name;
+};
+ at property struct Data data;
+ at end
+ at implementation MyData
+ at end


        


More information about the cfe-commits mailing list