Use clang::VarDecl name instead of llvm::GlobalVariable name.
llvm::GLobalVariable name may not match user visibile name for function static variables.

llvm-svn: 102644
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 4991c0f..4963e73 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1601,7 +1601,7 @@
     T = CGM.getContext().getConstantArrayType(ET, ConstVal,
                                            ArrayType::Normal, 0);
   }
-  llvm::StringRef DeclName = Var->getName();
+  llvm::StringRef DeclName = D->getName();
   llvm::DIDescriptor DContext = 
     getContextDescriptor(dyn_cast<Decl>(D->getDeclContext()), Unit);
   DebugFactory.CreateGlobalVariable(DContext, DeclName,
diff --git a/clang/test/CodeGen/2009-10-20-GlobalDebug.c b/clang/test/CodeGen/2009-10-20-GlobalDebug.c
index 99be469..1db37de 100644
--- a/clang/test/CodeGen/2009-10-20-GlobalDebug.c
+++ b/clang/test/CodeGen/2009-10-20-GlobalDebug.c
@@ -1,4 +1,8 @@
 // RUN: %clang -ccc-host-triple i386-apple-darwin10 -S -g -dA %s -o - | FileCheck %s
 int global;
-// CHECK: asciz "global" ## External Name
-int main() { return 0;}
+// CHECK: asciz   "global" ## External Name
+// CHECK: asciz   "localstatic"          ## External Name
+int main() { 
+  static int localstatic;
+  return 0;
+}