[llvm-commits] CVS: llvm/lib/CWriter/Writer.cpp

Chris Lattner lattner at cs.uiuc.edu
Sat May 31 22:38:14 PDT 2003


Changes in directory llvm/lib/CWriter:

Writer.cpp updated: 1.89 -> 1.90

---
Log message:

Fix a bug with casts to bool.  This fixes testcase UnitTests/2003-05-31-CastToBool.c



---
Diffs of the changes:

Index: llvm/lib/CWriter/Writer.cpp
diff -u llvm/lib/CWriter/Writer.cpp:1.89 llvm/lib/CWriter/Writer.cpp:1.90
--- llvm/lib/CWriter/Writer.cpp:1.89	Thu May 29 10:12:27 2003
+++ llvm/lib/CWriter/Writer.cpp	Sat May 31 22:36:51 2003
@@ -997,6 +997,12 @@
 }
 
 void CWriter::visitCastInst(CastInst &I) {
+  if (I.getType() == Type::BoolTy) {
+    Out << "(";
+    writeOperand(I.getOperand(0));
+    Out << " != 0)";
+    return;
+  }
   Out << "(";
   printType(Out, I.getType(), "", /*ignoreName*/false, /*namedContext*/false);
   Out << ")";
@@ -1005,7 +1011,7 @@
     // Avoid "cast to pointer from integer of different size" warnings
     Out << "(long)";  
   }
-
+  
   writeOperand(I.getOperand(0));
 }
 





More information about the llvm-commits mailing list