aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/CBackend/CBackend.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
commitd13bd22fbe238e0b1774b8426adbca1a5bf8f398 (patch)
tree766d1418b364dfe52fa235b2b3e3c6817a6ccb1c /lib/Target/CBackend/CBackend.cpp
parent074d84c746f6e4592be3e87ed56ea6b9059d0e82 (diff)
Fix a bug with casts to bool. This fixes testcase UnitTests/2003-05-31-CastToBool.c
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6507 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/CBackend/CBackend.cpp')
-rw-r--r--lib/Target/CBackend/CBackend.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp
index df95757200..a12afa7958 100644
--- a/lib/Target/CBackend/CBackend.cpp
+++ b/lib/Target/CBackend/CBackend.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));
}