aboutsummaryrefslogtreecommitdiffstats
path: root/tools/llvm2cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-03-01 20:55:43 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-03-01 20:55:43 +0000
commit7029725851520b3c5948a8b7bc0d2ae2aeda9430 (patch)
treecf0b7c7b280105c02b9bab6d00b4c85528f15f4b /tools/llvm2cpp
parent0d54b7df4f99fb18c3893455ad3864326f74feb6 (diff)
downloadexternal_llvm-7029725851520b3c5948a8b7bc0d2ae2aeda9430.zip
external_llvm-7029725851520b3c5948a8b7bc0d2ae2aeda9430.tar.gz
external_llvm-7029725851520b3c5948a8b7bc0d2ae2aeda9430.tar.bz2
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
Diffstat (limited to 'tools/llvm2cpp')
-rw-r--r--tools/llvm2cpp/CppWriter.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/llvm2cpp/CppWriter.cpp b/tools/llvm2cpp/CppWriter.cpp
index 483016e..fb87b90 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<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 << ");";