diff options
author | Chris Lattner <sabre@nondot.org> | 2003-06-01 03:36:51 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-06-01 03:36:51 +0000 |
commit | 886fca4dc2a62d9ee8815ac93d460fed5c061b48 (patch) | |
tree | 66ebc1ad961bc0a456793e51da79c76f46be93d6 /llvm/lib/CWriter/Writer.cpp | |
parent | 791ac1a4c853a80caea68a463cab8814aec5e10a (diff) | |
download | bcm5719-llvm-886fca4dc2a62d9ee8815ac93d460fed5c061b48.tar.gz bcm5719-llvm-886fca4dc2a62d9ee8815ac93d460fed5c061b48.zip |
Fix a bug with casts to bool. This fixes testcase UnitTests/2003-05-31-CastToBool.c
llvm-svn: 6507
Diffstat (limited to 'llvm/lib/CWriter/Writer.cpp')
-rw-r--r-- | llvm/lib/CWriter/Writer.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/CWriter/Writer.cpp b/llvm/lib/CWriter/Writer.cpp index df95757200b..a12afa79581 100644 --- a/llvm/lib/CWriter/Writer.cpp +++ b/llvm/lib/CWriter/Writer.cpp @@ -997,6 +997,12 @@ void CWriter::visitBinaryOperator(Instruction &I) { } 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 @@ void CWriter::visitCastInst(CastInst &I) { // Avoid "cast to pointer from integer of different size" warnings Out << "(long)"; } - + writeOperand(I.getOperand(0)); } |