Fixed StmtPrinter to handle GCC extension to the ternary operator "?:" where

the LHS subexpression can be NULL.  Patch provided by Nuno Lopes!

llvm-svn: 44328
This commit is contained in:
Ted Kremenek 2007-11-26 18:27:54 +00:00
parent 138988765c
commit ebb1c0ca74
1 changed files with 10 additions and 3 deletions

View File

@ -673,9 +673,16 @@ void StmtPrinter::VisitCompoundAssignOperator(CompoundAssignOperator *Node) {
}
void StmtPrinter::VisitConditionalOperator(ConditionalOperator *Node) {
PrintExpr(Node->getCond());
OS << " ? ";
PrintExpr(Node->getLHS());
OS << " : ";
if (Node->getLHS()) {
OS << " ? ";
PrintExpr(Node->getLHS());
OS << " : ";
}
else { // Handle GCC extention where LHS can be NULL.
OS << " ?: ";
}
PrintExpr(Node->getRHS());
}