Make output for ConstantInt construction correct for any bitwidth.

llvm-svn: 34809
This commit is contained in:
Reid Spencer 2007-03-01 20:55:43 +00:00
parent 4326cf5c51
commit 07761199e0
1 changed files with 2 additions and 1 deletions

View File

@ -665,7 +665,8 @@ void CppWriter::printConstant(const Constant *CV) {
}
if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
Out << "ConstantInt* " << constName << " = ConstantInt::get("
<< typeName << ", " << CI->getZExtValue() << ");";
<< "APInt(cast<IntegerTyp>(" << typeName << ")->getBitWidth(),"
<< " \"" << CI->getValue().toStringSigned(10) << "\", 10));";
} else if (isa<ConstantAggregateZero>(CV)) {
Out << "ConstantAggregateZero* " << constName
<< " = ConstantAggregateZero::get(" << typeName << ");";