Debug Info: for static member variables, move AT_MIPS_linkage_name from
TAG_member inside a class to the specification DIE.

Having AT_MIPS_linkage_name on TAG_member caused old gdb (GNU 6.3.50) to
error out. Also gcc 4.7 has AT_MIPS_linkage_name on the specification DIE.

rdar://problem/13291234


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176120 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index 93b00fb..c023afd 100644
--- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -1349,7 +1349,10 @@
     // Add linkage name.
     StringRef LinkageName = GV.getLinkageName();
     if (!LinkageName.empty() && isGlobalVariable)
-      addString(VariableDIE, dwarf::DW_AT_MIPS_linkage_name,
+      // For static member variables, AT_MIPS_linkage_name should be on
+      // specification DIE to make old gdb work.
+      addString(IsStaticMember && VariableSpecDIE ?
+                VariableSpecDIE : VariableDIE, dwarf::DW_AT_MIPS_linkage_name,
                 getRealLinkageName(LinkageName));
   } else if (const ConstantInt *CI =
              dyn_cast_or_null<ConstantInt>(GV.getConstant())) {