]> granicus.if.org Git - clang/commitdiff
Fix bug in ParentMap::isConsumedExpr. A BinaryOperator always "consumes" the
authorTed Kremenek <kremenek@apple.com>
Wed, 8 Apr 2009 18:49:36 +0000 (18:49 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 8 Apr 2009 18:49:36 +0000 (18:49 +0000)
value of its subexpressions unless it is a comma (in which case it doesn't
consume the left subexpression).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68628 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ParentMap.cpp

index 877b43b6de9234b3fc3cbd076b1259c11e75efee..33731c63ed8902ce3c9a21319ebd41d8d499acce 100644 (file)
@@ -66,7 +66,9 @@ bool ParentMap::isConsumedExpr(Expr* E) const {
       return true;
     case Stmt::BinaryOperatorClass: {
       BinaryOperator *BE = cast<BinaryOperator>(P);
-      return BE->getOpcode()==BinaryOperator::Comma && DirectChild==BE->getLHS();
+      // If it is a comma, only the left side is consumed.
+      // If it isn't a comma, both sides are consumed.
+      return BE->getOpcode()!=BinaryOperator::Comma || DirectChild==BE->getLHS();
     }
     case Stmt::ForStmtClass:
       return DirectChild == cast<ForStmt>(P)->getCond();