]> granicus.if.org Git - clang/commitdiff
DebugInfo: Location information for scalar new expressions
authorDavid Blaikie <dblaikie@gmail.com>
Wed, 10 Dec 2014 19:04:09 +0000 (19:04 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Wed, 10 Dec 2014 19:04:09 +0000 (19:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223937 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExprCXX.cpp
test/CodeGenCXX/debug-info-line.cpp

index 4876b1a6edaedf74ad19f309321857624cac6abb..6d0e427732a47a9d873ef23cc4955e0ac238c697 100644 (file)
@@ -754,14 +754,15 @@ static llvm::Value *EmitCXXNewAllocSize(CodeGenFunction &CGF,
 }
 
 static void StoreAnyExprIntoOneUnit(CodeGenFunction &CGF, const Expr *Init,
-                                    QualType AllocType, llvm::Value *NewPtr) {
+                                    QualType AllocType, llvm::Value *NewPtr,
+                                    SourceLocation DbgLoc = SourceLocation()) {
   // FIXME: Refactor with EmitExprAsInit.
   CharUnits Alignment = CGF.getContext().getTypeAlignInChars(AllocType);
   switch (CGF.getEvaluationKind(AllocType)) {
   case TEK_Scalar:
-    CGF.EmitScalarInit(Init, nullptr, CGF.MakeAddrLValue(NewPtr, AllocType,
-                                                         Alignment),
-                       false);
+    CGF.EmitScalarInit(Init, nullptr,
+                       CGF.MakeAddrLValue(NewPtr, AllocType, Alignment), false,
+                       DbgLoc);
     return;
   case TEK_Complex:
     CGF.EmitComplexExprIntoLValue(Init, CGF.MakeAddrLValue(NewPtr, AllocType,
@@ -1023,7 +1024,8 @@ static void EmitNewInitializer(CodeGenFunction &CGF, const CXXNewExpr *E,
     CGF.EmitNewArrayInitializer(E, ElementType, NewPtr, NumElements,
                                 AllocSizeWithoutCookie);
   else if (const Expr *Init = E->getInitializer())
-    StoreAnyExprIntoOneUnit(CGF, Init, E->getAllocatedType(), NewPtr);
+    StoreAnyExprIntoOneUnit(CGF, Init, E->getAllocatedType(), NewPtr,
+                            E->getStartLoc());
 }
 
 /// Emit a call to an operator new or operator delete function, as implicitly
index 125c53ba500f9e91d7c43b3d7de9ca63ad0f053e..0ec977e591a57edfe4fd2a88dae306e415bd00e1 100644 (file)
@@ -99,6 +99,16 @@ void f9(int i) {
       src1)[src2()];
 }
 
+void *operator new(unsigned long, void *);
+
+// CHECK-LABEL: define
+void f10() {
+  void *void_src();
+  ( // CHECK: store {{.*}} !dbg [[DBG_F10:!.*]]
+#line 1100
+      new (void_src()) int(src()));
+}
+
 // CHECK: [[DBG_F1]] = metadata !{i32 100,
 // CHECK: [[DBG_FOO_VALUE]] = metadata !{i32 200,
 // CHECK: [[DBG_FOO_REF]] = metadata !{i32 202,
@@ -111,3 +121,4 @@ void f9(int i) {
 // CHECK: [[DBG_F7]] = metadata !{i32 800,
 // CHECK: [[DBG_F8]] = metadata !{i32 900,
 // CHECK: [[DBG_F9]] = metadata !{i32 1000,
+// CHECK: [[DBG_F10]] = metadata !{i32 1100,