]> granicus.if.org Git - clang/commitdiff
Merging r226382:
authorHans Wennborg <hans@hanshq.net>
Mon, 2 Feb 2015 21:02:01 +0000 (21:02 +0000)
committerHans Wennborg <hans@hanshq.net>
Mon, 2 Feb 2015 21:02:01 +0000 (21:02 +0000)
------------------------------------------------------------------------
r226382 | dblaikie | 2015-01-17 16:12:58 -0800 (Sat, 17 Jan 2015) | 7 lines

DebugInfo: Correct the debug location of non-static data member initializers

This was causing some trouble for otherwise dead code removed in r225085
(reverted in r225361). The location being set for function arguments was
leaking out to the call which wasn't setting its own location (so a
quality bug turned into a crasher with r225085). Fix this so r225085 can
be recommitted.
------------------------------------------------------------------------

git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_36@227859 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/DeclCXX.cpp
lib/CodeGen/CGClass.cpp
test/CodeGenCXX/debug-info-line.cpp

index a6d9d411eef31002e8c170dbc11db7305819bd5a..9af8c4b242a6a4750244b2f1a30e314dfaa3c42d 100644 (file)
@@ -1693,12 +1693,12 @@ const Type *CXXCtorInitializer::getBaseClass() const {
 }
 
 SourceLocation CXXCtorInitializer::getSourceLocation() const {
-  if (isAnyMemberInitializer())
-    return getMemberLocation();
-
   if (isInClassMemberInitializer())
     return getAnyMember()->getLocation();
   
+  if (isAnyMemberInitializer())
+    return getMemberLocation();
+
   if (TypeSourceInfo *TSInfo = Initializee.get<TypeSourceInfo*>())
     return TSInfo->getTypeLoc().getLocalSourceRange().getBegin();
   
index 92c694a76de7e64b0f6353fe9dfa9a5eafde3591..d72eda95d7cf4c3299b4475f5484bdcef695c8f2 100644 (file)
@@ -544,7 +544,7 @@ static void EmitMemberInitializer(CodeGenFunction &CGF,
                                   CXXCtorInitializer *MemberInit,
                                   const CXXConstructorDecl *Constructor,
                                   FunctionArgList &Args) {
-  ApplyDebugLocation Loc(CGF, MemberInit->getMemberLocation());
+  ApplyDebugLocation Loc(CGF, MemberInit->getSourceLocation());
   assert(MemberInit->isAnyMemberInitializer() &&
          "Must have member initializer!");
   assert(MemberInit->getInit() && "Must have initializer!");
@@ -598,7 +598,6 @@ static void EmitMemberInitializer(CodeGenFunction &CGF,
   ArrayRef<VarDecl *> ArrayIndexes;
   if (MemberInit->getNumArrayIndices())
     ArrayIndexes = MemberInit->getArrayIndexes();
-  ApplyDebugLocation DL(CGF, MemberInit->getMemberLocation());
   CGF.EmitInitializerForField(Field, LHS, MemberInit->getInit(), ArrayIndexes);
 }
 
index a5cc6392b4fcf67b6e87ad7ae19d3f83e8b1568d..cce4a98861bbb68af69260938079336dae948baf 100644 (file)
@@ -166,6 +166,23 @@ void f13() {
   F13_IMPL;
 }
 
+struct f14 {
+  f14(int);
+};
+
+// CHECK-LABEL: define
+// CHECK-LABEL: define
+// CHECK-LABEL: define
+struct {
+// CHECK: call {{.*}}, !dbg [[DBG_F14_CTOR_CALL:![0-9]*]]
+#line 1600
+  f14 v
+      =
+      1;
+} f14_inst;
+
+// CHECK-LABEL: define
+
 // CHECK: [[DBG_F1]] = !MDLocation(line: 100,
 // CHECK: [[DBG_FOO_VALUE]] = !MDLocation(line: 200,
 // CHECK: [[DBG_FOO_REF]] = !MDLocation(line: 202,