From ff4ca2e0883d95cbd97e09e56bee8c73fa384e6a Mon Sep 17 00:00:00 2001 From: Anton Korobeynikov Date: Sun, 5 Oct 2008 15:07:06 +0000 Subject: [PATCH] Emit type-correct constant null. Also fix a typo. Patch by Robert G. Jakabosky! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57110 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/CppBackend/CPPBackend.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp index e435f16d1ed..75a77a8159e 100644 --- a/lib/Target/CppBackend/CPPBackend.cpp +++ b/lib/Target/CppBackend/CPPBackend.cpp @@ -722,16 +722,12 @@ namespace { std::string constName(getCppName(CV)); std::string typeName(getCppName(CV->getType())); - if (CV->isNullValue()) { - Out << "Constant* " << constName << " = Constant::getNullValue(" - << typeName << ");"; - nl(Out); - return; - } + if (isa(CV)) { // Skip variables and functions, we emit them elsewhere return; } + if (const ConstantInt *CI = dyn_cast(CV)) { std::string constValue = CI->getValue().toString(10, true); Out << "ConstantInt* " << constName << " = ConstantInt::get(APInt(" @@ -742,7 +738,7 @@ namespace { << " = ConstantAggregateZero::get(" << typeName << ");"; } else if (isa(CV)) { Out << "ConstantPointerNull* " << constName - << " = ConstanPointerNull::get(" << typeName << ");"; + << " = ConstantPointerNull::get(" << typeName << ");"; } else if (const ConstantFP *CFP = dyn_cast(CV)) { Out << "ConstantFP* " << constName << " = "; printCFP(CFP);