summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CWriter/Writer.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-06-01 03:36:51 +0000
committerChris Lattner <sabre@nondot.org>2003-06-01 03:36:51 +0000
commit886fca4dc2a62d9ee8815ac93d460fed5c061b48 (patch)
tree66ebc1ad961bc0a456793e51da79c76f46be93d6 /llvm/lib/CWriter/Writer.cpp
parent791ac1a4c853a80caea68a463cab8814aec5e10a (diff)
downloadbcm5719-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.cpp8
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));
}
OpenPOWER on IntegriCloud