From: Zhanyong Wan Date: Mon, 22 Nov 2010 19:32:14 +0000 (+0000) Subject: Stylistic changes to CFG.cpp: X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=36f327c309b1fb6b82f1987190f0be74000b14c1;p=clang Stylistic changes to CFG.cpp: 1. "no 'else' after 'return'" -- this is for conformance with the coding standards. 2. move 'else' to the line of the previous '}' -- this is for consistency. Reviewed by kremenek. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119983 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp index c5ac453d4d..4b89a54023 100644 --- a/lib/Analysis/CFG.cpp +++ b/lib/Analysis/CFG.cpp @@ -960,8 +960,7 @@ CFGBlock *CFGBuilder::VisitBinaryOperator(BinaryOperator *B, if (RHSBlock) { if (badCFG) return 0; - } - else { + } else { // Create an empty block for cases where the RHS doesn't require // any explicit statements in the CFG. RHSBlock = createBlock(); @@ -986,13 +985,15 @@ CFGBlock *CFGBuilder::VisitBinaryOperator(BinaryOperator *B, Block = LHSBlock; return addStmt(B->getLHS()); } - else if (B->getOpcode() == BO_Comma) { // , + + if (B->getOpcode() == BO_Comma) { // , autoCreateBlock(); AppendStmt(Block, B, asc); addStmt(B->getRHS()); return addStmt(B->getLHS()); } - else if (B->isAssignmentOp()) { + + if (B->isAssignmentOp()) { if (asc.alwaysAdd()) { autoCreateBlock(); AppendStmt(Block, B, asc); @@ -1645,13 +1646,13 @@ CFGBlock* CFGBuilder::VisitForStmt(ForStmt* F) { if (Stmt* I = F->getInit()) { Block = createBlock(); return addStmt(I); - } else { - // There is no loop initialization. We are thus basically a while loop. - // NULL out Block to force lazy block construction. - Block = NULL; - Succ = EntryConditionBlock; - return EntryConditionBlock; } + + // There is no loop initialization. We are thus basically a while loop. + // NULL out Block to force lazy block construction. + Block = NULL; + Succ = EntryConditionBlock; + return EntryConditionBlock; } CFGBlock *CFGBuilder::VisitMemberExpr(MemberExpr *M, AddStmtChoice asc) { @@ -2248,8 +2249,7 @@ CFGBlock* CFGBuilder::VisitCaseStmt(CaseStmt* CS) { if (TopBlock) { AddSuccessor(LastBlock, CaseBlock); Succ = TopBlock; - } - else { + } else { // This block is now the implicit successor of other blocks. Succ = CaseBlock; } @@ -2581,7 +2581,7 @@ CFGBlock *CFGBuilder::VisitBinaryOperatorForTemporaryDtors(BinaryOperator *E) { return ConfluenceBlock; } - else if (E->isAssignmentOp()) { + if (E->isAssignmentOp()) { // For assignment operator (=) LHS expression is visited // before RHS expression. For destructors visit them in reverse order. CFGBlock *RHSBlock = VisitForTemporaryDtors(E->getRHS()); @@ -2792,12 +2792,11 @@ CFG::BlkExprNumTy CFG::getBlkExprNum(const Stmt* S) { unsigned CFG::getNumBlkExprs() { if (const BlkExprMapTy* M = reinterpret_cast(BlkExprMap)) return M->size(); - else { - // We assume callers interested in the number of BlkExprs will want - // the map constructed if it doesn't already exist. - BlkExprMap = (void*) PopulateBlkExprMap(*this); - return reinterpret_cast(BlkExprMap)->size(); - } + + // We assume callers interested in the number of BlkExprs will want + // the map constructed if it doesn't already exist. + BlkExprMap = (void*) PopulateBlkExprMap(*this); + return reinterpret_cast(BlkExprMap)->size(); } //===----------------------------------------------------------------------===// @@ -2859,7 +2858,7 @@ public: if (DeclStmt* DS = dyn_cast(SE.getStmt())) { DeclMap[DS->getSingleDecl()] = P; - + } else if (IfStmt* IS = dyn_cast(SE.getStmt())) { if (VarDecl* VD = IS->getConditionVariable()) DeclMap[VD] = P; @@ -3053,10 +3052,9 @@ static void print_elem(llvm::raw_ostream &OS, StmtPrinterHelper* Helper, S->printPretty(OS, Helper, PrintingPolicy(Helper->getLangOpts())); if (isa(S)) { - OS << " (OperatorCall)"; - } - else if (isa(S)) { - OS << " (BindTemporary)"; + OS << " (OperatorCall)"; + } else if (isa(S)) { + OS << " (BindTemporary)"; } // Expressions need a newline.