Make output for ConstantInt construction correct for any bitwidth.
authorReid Spencer <rspencer@reidspencer.com>
Thu, 1 Mar 2007 20:55:43 +0000 (20:55 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Thu, 1 Mar 2007 20:55:43 +0000 (20:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34809 91177308-0d34-0410-b5e6-96231b3b80d8

tools/llvm2cpp/CppWriter.cpp

index 483016ebf69b56ccd0534db7b51825f4fa4e1591..fb87b902c858bd2ccd3e08f65685b2880bdc19c6 100644 (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 << ");";