aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/CBackend/Writer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Target/CBackend/Writer.cpp')
-rw-r--r--lib/Target/CBackend/Writer.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp
index df95757200..a12afa7958 100644
--- a/lib/Target/CBackend/Writer.cpp
+++ b/lib/Target/CBackend/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));
}