]> granicus.if.org Git - clang/commitdiff
DebugInfo: Correct the debug location of non-static data member initializers
authorDavid Blaikie <dblaikie@gmail.com>
Sun, 18 Jan 2015 00:12:58 +0000 (00:12 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Sun, 18 Jan 2015 00:12:58 +0000 (00:12 +0000)
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/trunk@226382 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 02b5059c5d3b9889c37d716a6cacb4dc60135dbf..bcfd0d02b4ebfdfbfb7a4169505cc78f18782947 100644 (file)
@@ -173,12 +173,12 @@ struct f14 {
 // CHECK-LABEL: define
 // CHECK-LABEL: define
 // CHECK-LABEL: define
+struct {
 // CHECK: call {{.*}}, !dbg [[DBG_F14_CTOR_CALL:![0-9]*]]
-// FIXME: The ctor call should be attributed to the line of the NSDMI, not the
-// start of this declaration.
 #line 1600
-struct {
-  f14 v = 1;
+  f14 v
+      =
+      1;
 } f14_inst;
 
 // CHECK-LABEL: define