From b0d0ea042116c1f451d3db8ceff9f1dd92bc36d2 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Sun, 2 Aug 2009 21:18:22 +0000 Subject: [PATCH] use CodeGenModule::EmitNullConstant in a couple of places. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77915 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGDecl.cpp | 5 ++--- lib/CodeGen/CGExprConstant.cpp | 2 +- lib/CodeGen/CodeGenModule.cpp | 1 + 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index 7028e74491..9fd571b816 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -105,9 +105,8 @@ CodeGenFunction::CreateStaticBlockVarDecl(const VarDecl &D, const llvm::Type *LTy = CGM.getTypes().ConvertTypeForMem(Ty); return new llvm::GlobalVariable(CGM.getModule(), LTy, Ty.isConstant(getContext()), Linkage, - llvm::Constant::getNullValue(LTy), Name, - 0, D.isThreadSpecified(), - Ty.getAddressSpace()); + CGM.EmitNullConstant(D.getType()), Name, 0, + D.isThreadSpecified(), Ty.getAddressSpace()); } void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D) { diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index dbb1bdcc6e..3a1eac9e04 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -772,5 +772,5 @@ llvm::Constant *CodeGenModule::EmitConstantExpr(const Expr *E, llvm::Constant *CodeGenModule::EmitNullConstant(QualType T) { // Always return an LLVM null constant for now; this will change when we // get support for IRGen of member pointers. - return llvm::Constant::getNullValue(getTypes().ConvertType(T)); + return llvm::Constant::getNullValue(getTypes().ConvertTypeForMem(T)); } diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index ec9a97aabd..c37fbe2efc 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -810,6 +810,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) { // exists. A use may still exists, however, so we still may need // to do a RAUW. assert(!ASTTy->isIncompleteType() && "Unexpected incomplete type"); + Init = EmitNullConstant(D->getType()); Init = llvm::Constant::getNullValue(getTypes().ConvertTypeForMem(ASTTy)); } else { Init = EmitConstantExpr(D->getInit(), D->getType()); -- 2.40.0