From 6dace61730e3a7a3d6cd01ce34dbe611cb55ec8c Mon Sep 17 00:00:00 2001 From: Zhanyong Wan Date: Mon, 22 Nov 2010 08:45:56 +0000 Subject: Fix PR8419. Reviewed by kremenek and xuzhongxing. llvm-svn: 119960 --- clang/lib/Analysis/CFG.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'clang/lib/Analysis/CFG.cpp') diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index b58e9826d33..c5ac453d4dd 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -296,6 +296,7 @@ private: CFGBlock *VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E, AddStmtChoice asc); CFGBlock *VisitStmtExpr(StmtExpr *S, AddStmtChoice asc); CFGBlock *VisitSwitchStmt(SwitchStmt *S); + CFGBlock *VisitUnaryOperator(UnaryOperator *U, AddStmtChoice asc); CFGBlock *VisitWhileStmt(WhileStmt *W); CFGBlock *Visit(Stmt *S, AddStmtChoice asc = AddStmtChoice::NotAlwaysAdd); @@ -886,6 +887,9 @@ tryAgain: case Stmt::SwitchStmtClass: return VisitSwitchStmt(cast(S)); + case Stmt::UnaryOperatorClass: + return VisitUnaryOperator(cast(S), asc); + case Stmt::WhileStmtClass: return VisitWhileStmt(cast(S)); } @@ -922,6 +926,19 @@ CFGBlock *CFGBuilder::VisitAddrLabelExpr(AddrLabelExpr *A, return Block; } +CFGBlock *CFGBuilder::VisitUnaryOperator(UnaryOperator *U, + AddStmtChoice asc) { + if (asc.alwaysAdd()) { + autoCreateBlock(); + AppendStmt(Block, U, asc); + } + + bool asLVal = U->isIncrementDecrementOp(); + return Visit(U->getSubExpr(), + asLVal ? AddStmtChoice::AsLValueNotAlwaysAdd : + AddStmtChoice::NotAlwaysAdd); +} + CFGBlock *CFGBuilder::VisitBinaryOperator(BinaryOperator *B, AddStmtChoice asc) { if (B->isLogicalOp()) { // && or || -- cgit v1.2.3