From: Ted Kremenek Date: Mon, 26 Nov 2007 18:27:54 +0000 (+0000) Subject: Fixed StmtPrinter to handle GCC extension to the ternary operator "?:" where X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8e911c42ad6a5ae0fe0dd46058bd13236a0e9026;p=clang Fixed StmtPrinter to handle GCC extension to the ternary operator "?:" where the LHS subexpression can be NULL. Patch provided by Nuno Lopes! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44328 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/AST/StmtPrinter.cpp b/AST/StmtPrinter.cpp index c68257ec33..9822e4789e 100644 --- a/AST/StmtPrinter.cpp +++ b/AST/StmtPrinter.cpp @@ -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()); }