Make output for ConstantInt construction correct for any bitwidth.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34809 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Spencer 2007-03-01 20:55:43 +00:00
parent 0d54b7df4f
commit 7029725851

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 << ");";