]> granicus.if.org Git - clang/commitdiff
Fixed StmtPrinter to handle GCC extension to the ternary operator "?:" where
authorTed Kremenek <kremenek@apple.com>
Mon, 26 Nov 2007 18:27:54 +0000 (18:27 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 26 Nov 2007 18:27:54 +0000 (18:27 +0000)
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

AST/StmtPrinter.cpp

index c68257ec3365272e5a1b0397def96776aa9f795c..9822e4789e6688349ebb77c80560d1b8fdcd14cf 100644 (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());
 }