Emit debug information for global and static variables when -g is specified.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51993 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp
index 8723a66..5451d4a 100644
--- a/lib/CodeGen/CGDecl.cpp
+++ b/lib/CodeGen/CGDecl.cpp
@@ -116,6 +116,15 @@
   }
 
   DMEntry = GV;
+
+  // Emit global variable debug descriptor for static vars.
+  CGDebugInfo *DI = CGM.getDebugInfo();
+  if(DI) {
+    if(D.getLocation().isValid())
+      DI->setLocation(D.getLocation());
+    DI->EmitGlobalVariable(static_cast<llvm::GlobalVariable *>(GV), &D);
+  }
+
 }
   
 /// EmitLocalBlockVarDecl - Emit code and set up an entry in LocalDeclMap for a