[llvm-commits] CVS: llvm/tools/llvm2cpp/CppWriter.cpp

Zhou Sheng zhousheng00 at gmail.com
Thu Jan 11 04:25:01 PST 2007



Changes in directory llvm/tools/llvm2cpp:

CppWriter.cpp updated: 1.28 -> 1.29
---
Log message:

For PR1043: http://llvm.org/PR1043 :
Merge ConstantIntegral and ConstantBool into ConstantInt.
Remove ConstantIntegral and ConstantBool from LLVM.


---
Diffs of the changes:  (+7 -6)

 CppWriter.cpp |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)


Index: llvm/tools/llvm2cpp/CppWriter.cpp
diff -u llvm/tools/llvm2cpp/CppWriter.cpp:1.28 llvm/tools/llvm2cpp/CppWriter.cpp:1.29
--- llvm/tools/llvm2cpp/CppWriter.cpp:1.28	Sat Jan  6 01:24:44 2007
+++ llvm/tools/llvm2cpp/CppWriter.cpp	Thu Jan 11 06:24:14 2007
@@ -668,12 +668,13 @@
     // Skip variables and functions, we emit them elsewhere
     return;
   }
-  if (const ConstantBool *CB = dyn_cast<ConstantBool>(CV)) {
-    Out << "ConstantBool* " << constName << " = ConstantBool::get(" 
-        << (CB->getValue() ? "true" : "false") << ");";
-  } else if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
-    Out << "ConstantInt* " << constName << " = ConstantInt::get(" 
-        << typeName << ", " << CI->getZExtValue() << ");";
+  if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
+    if (CI->getType() == Type::BoolTy)
+      Out << "ConstantInt* " << constName << " = ConstantInt::get(" 
+          << (CI->getBoolValue() ? "true" : "false") << ");";
+    else
+      Out << "ConstantInt* " << constName << " = ConstantInt::get(" 
+          << typeName << ", " << CI->getZExtValue() << ");";
   } else if (isa<ConstantAggregateZero>(CV)) {
     Out << "ConstantAggregateZero* " << constName 
         << " = ConstantAggregateZero::get(" << typeName << ");";






More information about the llvm-commits mailing list