Use the right definition when emitting a global variable. Fixes PR5564.

llvm-svn: 94555
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 4eb8bd8..ebd3df1 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -979,7 +979,9 @@
   QualType ASTTy = D->getType();
   bool NonConstInit = false;
 
-  if (D->getInit() == 0) {
+  const Expr *InitExpr = D->getDefinition();
+  
+  if (!InitExpr) {
     // This is a tentative definition; tentative definitions are
     // implicitly initialized with { 0 }.
     //
@@ -992,10 +994,10 @@
     assert(!ASTTy->isIncompleteType() && "Unexpected incomplete type");
     Init = EmitNullConstant(D->getType());
   } else {
-    Init = EmitConstantExpr(D->getInit(), D->getType());
+    Init = EmitConstantExpr(InitExpr, D->getType());
 
     if (!Init) {
-      QualType T = D->getInit()->getType();
+      QualType T = InitExpr->getType();
       if (getLangOptions().CPlusPlus) {
         EmitCXXGlobalVarDeclInitFunc(D);
         Init = EmitNullConstant(T);