[PATCH] D71042: [DebugInfo] Ensure fallback artificial location is available for cleanups

Vedant Kumar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 5 09:55:45 PST 2019


vsk updated this revision to Diff 232373.
vsk retitled this revision from "WIP: [DebugInfo] Ensure fallback artificial location is available for cleanups" to "[DebugInfo] Ensure fallback artificial location is available for cleanups".
vsk edited the summary of this revision.
vsk added a comment.

Added a test.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71042/new/

https://reviews.llvm.org/D71042

Files:
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGenObjCXX/property-object-cleanup.mm


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
+
+ 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
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<ApplyDebugLocation> 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/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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71042.232373.patch
Type: text/x-patch
Size: 2056 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191205/0123d0d4/attachment.bin>


More information about the cfe-commits mailing list