Oops, didn't handle hex values correctly. :(
authorChris Lattner <sabre@nondot.org>
Mon, 15 Oct 2001 00:05:03 +0000 (00:05 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 15 Oct 2001 00:05:03 +0000 (00:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@815 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/ConstPoolVals.cpp

index 25c58cbd65be635d82c54f33b1e420072d5d2be5..3b543cbcbe56f120b6c10600c4d1a54096e38423 100644 (file)
@@ -168,7 +168,7 @@ string ConstPoolArray::getStrValue() const {
   // 
   const Type *ETy = cast<ArrayType>(getType())->getElementType();
   bool isString = (ETy == Type::SByteTy || ETy == Type::UByteTy);
-  for (unsigned i = 0; i < Operands.size(); i++)
+  for (unsigned i = 0; i < Operands.size(); ++i)
     if (ETy == Type::SByteTy &&
         cast<ConstPoolSInt>(Operands[i])->getValue() < 0) {
       isString = false;
@@ -177,7 +177,7 @@ string ConstPoolArray::getStrValue() const {
 
   if (isString) {
     Result = "c\"";
-    for (unsigned i = 0; i < Operands.size(); i++) {
+    for (unsigned i = 0; i < Operands.size(); ++i) {
       unsigned char C = (ETy == Type::SByteTy) ?
         (unsigned char)cast<ConstPoolSInt>(Operands[i])->getValue() :
         (unsigned char)cast<ConstPoolUInt>(Operands[i])->getValue();
@@ -186,8 +186,8 @@ string ConstPoolArray::getStrValue() const {
         Result += C;
       } else {
         Result += '\\';
-        Result += (C/16)+'0';
-        Result += (C&15)+'0';
+        Result += ( C/16  < 10) ? ( C/16 +'0') : ( C/16 -10+'A');
+        Result += ((C&15) < 10) ? ((C&15)+'0') : ((C&15)-10+'A');
       }
     }
     Result += "\"";