llvm.org GIT mirror llvm / ff4ca2e
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 Anton Korobeynikov 12 years ago
1 changed file(s) with 3 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
721721
722722 std::string constName(getCppName(CV));
723723 std::string typeName(getCppName(CV->getType()));
724 if (CV->isNullValue()) {
725 Out << "Constant* " << constName << " = Constant::getNullValue("
726 << typeName << ");";
727 nl(Out);
728 return;
729 }
724
730725 if (isa(CV)) {
731726 // Skip variables and functions, we emit them elsewhere
732727 return;
733728 }
729
734730 if (const ConstantInt *CI = dyn_cast(CV)) {
735731 std::string constValue = CI->getValue().toString(10, true);
736732 Out << "ConstantInt* " << constName << " = ConstantInt::get(APInt("
741737 << " = ConstantAggregateZero::get(" << typeName << ");";
742738 } else if (isa(CV)) {
743739 Out << "ConstantPointerNull* " << constName
744 << " = ConstanPointerNull::get(" << typeName << ");";
740 << " = ConstantPointerNull::get(" << typeName << ");";
745741 } else if (const ConstantFP *CFP = dyn_cast(CV)) {
746742 Out << "ConstantFP* " << constName << " = ";
747743 printCFP(CFP);