mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-15 05:24:01 +00:00
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
This commit is contained in:
@ -997,6 +997,12 @@ void CWriter::visitBinaryOperator(Instruction &I) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CWriter::visitCastInst(CastInst &I) {
|
void CWriter::visitCastInst(CastInst &I) {
|
||||||
|
if (I.getType() == Type::BoolTy) {
|
||||||
|
Out << "(";
|
||||||
|
writeOperand(I.getOperand(0));
|
||||||
|
Out << " != 0)";
|
||||||
|
return;
|
||||||
|
}
|
||||||
Out << "(";
|
Out << "(";
|
||||||
printType(Out, I.getType(), "", /*ignoreName*/false, /*namedContext*/false);
|
printType(Out, I.getType(), "", /*ignoreName*/false, /*namedContext*/false);
|
||||||
Out << ")";
|
Out << ")";
|
||||||
@ -1005,7 +1011,7 @@ void CWriter::visitCastInst(CastInst &I) {
|
|||||||
// Avoid "cast to pointer from integer of different size" warnings
|
// Avoid "cast to pointer from integer of different size" warnings
|
||||||
Out << "(long)";
|
Out << "(long)";
|
||||||
}
|
}
|
||||||
|
|
||||||
writeOperand(I.getOperand(0));
|
writeOperand(I.getOperand(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -997,6 +997,12 @@ void CWriter::visitBinaryOperator(Instruction &I) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CWriter::visitCastInst(CastInst &I) {
|
void CWriter::visitCastInst(CastInst &I) {
|
||||||
|
if (I.getType() == Type::BoolTy) {
|
||||||
|
Out << "(";
|
||||||
|
writeOperand(I.getOperand(0));
|
||||||
|
Out << " != 0)";
|
||||||
|
return;
|
||||||
|
}
|
||||||
Out << "(";
|
Out << "(";
|
||||||
printType(Out, I.getType(), "", /*ignoreName*/false, /*namedContext*/false);
|
printType(Out, I.getType(), "", /*ignoreName*/false, /*namedContext*/false);
|
||||||
Out << ")";
|
Out << ")";
|
||||||
@ -1005,7 +1011,7 @@ void CWriter::visitCastInst(CastInst &I) {
|
|||||||
// Avoid "cast to pointer from integer of different size" warnings
|
// Avoid "cast to pointer from integer of different size" warnings
|
||||||
Out << "(long)";
|
Out << "(long)";
|
||||||
}
|
}
|
||||||
|
|
||||||
writeOperand(I.getOperand(0));
|
writeOperand(I.getOperand(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user