aboutsummaryrefslogtreecommitdiff
path: root/tools/llvm2cpp/CppWriter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/llvm2cpp/CppWriter.cpp')
-rw-r--r--tools/llvm2cpp/CppWriter.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/tools/llvm2cpp/CppWriter.cpp b/tools/llvm2cpp/CppWriter.cpp
index 85c1ec7853..e69c722027 100644
--- a/tools/llvm2cpp/CppWriter.cpp
+++ b/tools/llvm2cpp/CppWriter.cpp
@@ -678,12 +678,11 @@ void CppWriter::printConstant(const Constant *CV) {
if (const ConstantBool *CB = dyn_cast<ConstantBool>(CV)) {
Out << "ConstantBool* " << constName << " = ConstantBool::get("
<< (CB->getValue() ? "true" : "false") << ");";
- } else if (const ConstantSInt *CI = dyn_cast<ConstantSInt>(CV)) {
- Out << "ConstantSInt* " << constName << " = ConstantSInt::get("
- << typeName << ", " << CI->getValue() << ");";
- } else if (const ConstantUInt *CI = dyn_cast<ConstantUInt>(CV)) {
- Out << "ConstantUInt* " << constName << " = ConstantUInt::get("
- << typeName << ", " << CI->getValue() << ");";
+ } else if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
+ Out << "ConstantInt* " << constName << " = ConstantInt::get("
+ << typeName << ", "
+ << (CV->getType()->isSigned() ? CI->getSExtValue() : CI->getZExtValue())
+ << ");";
} else if (isa<ConstantAggregateZero>(CV)) {
Out << "ConstantAggregateZero* " << constName
<< " = ConstantAggregateZero::get(" << typeName << ");";