From: Reid Spencer Date: Thu, 1 Mar 2007 20:55:43 +0000 (+0000) Subject: Make output for ConstantInt construction correct for any bitwidth. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=7029725851520b3c5948a8b7bc0d2ae2aeda9430;p=oota-llvm.git 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 --- diff --git a/tools/llvm2cpp/CppWriter.cpp b/tools/llvm2cpp/CppWriter.cpp index 483016ebf69..fb87b902c85 100644 --- a/tools/llvm2cpp/CppWriter.cpp +++ b/tools/llvm2cpp/CppWriter.cpp @@ -665,7 +665,8 @@ void CppWriter::printConstant(const Constant *CV) { } if (const ConstantInt *CI = dyn_cast(CV)) { Out << "ConstantInt* " << constName << " = ConstantInt::get(" - << typeName << ", " << CI->getZExtValue() << ");"; + << "APInt(cast(" << typeName << ")->getBitWidth()," + << " \"" << CI->getValue().toStringSigned(10) << "\", 10));"; } else if (isa(CV)) { Out << "ConstantAggregateZero* " << constName << " = ConstantAggregateZero::get(" << typeName << ");";