r224221 - DebugInfo: More accurate line information for placement new.

David Blaikie dblaikie at gmail.com
Sun Dec 14 10:48:19 PST 2014


Author: dblaikie
Date: Sun Dec 14 12:48:18 2014
New Revision: 224221

URL: http://llvm.org/viewvc/llvm-project?rev=224221&view=rev
Log:
DebugInfo: More accurate line information for placement new.

This actually came up as a break in UBSan tests (look for a follow-up
commit to this one to see the UBSan test fallout) when I tried a broader
fix to location information.

I have some other ideas about how to do that broader change & will keep
looking into it.

Modified:
    cfe/trunk/lib/CodeGen/CGExprCXX.cpp
    cfe/trunk/test/CodeGenCXX/debug-info-line.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=224221&r1=224220&r2=224221&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Sun Dec 14 12:48:18 2014
@@ -1269,6 +1269,9 @@ llvm::Value *CodeGenFunction::EmitCXXNew
                E->placement_arg_end(), /* CalleeDecl */ nullptr,
                /*ParamsToSkip*/ 1);
 
+  if (auto *DI = getDebugInfo())
+    DI->EmitLocation(Builder, E->getLocStart());
+
   // Emit the allocation call.  If the allocator is a global placement
   // operator, just "inline" it directly.
   RValue RV;

Modified: cfe/trunk/test/CodeGenCXX/debug-info-line.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-line.cpp?rev=224221&r1=224220&r2=224221&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info-line.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-line.cpp Sun Dec 14 12:48:18 2014
@@ -99,12 +99,13 @@ void f9(int i) {
       src1)[src2()];
 }
 
-void *operator new(decltype(sizeof(1)), void *);
+inline void *operator new(decltype(sizeof(1)), void *p) noexcept { return p; }
 
 // CHECK-LABEL: define
 void f10() {
   void *void_src();
-  ( // CHECK: store {{.*}} !dbg [[DBG_F10:!.*]]
+  ( // CHECK: icmp {{.*}} !dbg [[DBG_F10_ICMP:.*]]
+    // CHECK: store {{.*}} !dbg [[DBG_F10_STORE:!.*]]
 #line 1100
       new (void_src()) int(src()));
 }
@@ -121,4 +122,5 @@ void f10() {
 // CHECK: [[DBG_F7]] = metadata !{i32 800,
 // CHECK: [[DBG_F8]] = metadata !{i32 900,
 // CHECK: [[DBG_F9]] = metadata !{i32 1000,
-// CHECK: [[DBG_F10]] = metadata !{i32 1100,
+// CHECK: [[DBG_F10_ICMP]] = metadata !{i32 1100,
+// CHECK: [[DBG_F10_STORE]] = metadata !{i32 1100,





More information about the cfe-commits mailing list