diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-12-17 04:44:39 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-12-17 04:44:39 +0000 |
commit | 0a3ed3143b00f237decb1288c1ff574ae09eba4e (patch) | |
tree | 34f68cb82244fd396193d9ff970e637a73282879 /lib/Analysis/CFG.cpp | |
parent | 9c39acfda88268bcc7fb5521b55ce41942dcb3b0 (diff) |
Rename several methods/functions in the analyzer
to start with lowercase characters. No
functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122035 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/CFG.cpp')
-rw-r--r-- | lib/Analysis/CFG.cpp | 156 |
1 files changed, 78 insertions, 78 deletions
diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp index 0f32614d2b..0db9598853 100644 --- a/lib/Analysis/CFG.cpp +++ b/lib/Analysis/CFG.cpp @@ -379,12 +379,12 @@ private: void prependAutomaticObjDtorsWithTerminator(CFGBlock* Blk, LocalScope::const_iterator B, LocalScope::const_iterator E); - void AddSuccessor(CFGBlock *B, CFGBlock *S) { + void addSuccessor(CFGBlock *B, CFGBlock *S) { B->addSuccessor(S, cfg->getBumpVectorContext()); } /// TryResult - a class representing a variant over the values - /// 'true', 'false', or 'unknown'. This is returned by TryEvaluateBool, + /// 'true', 'false', or 'unknown'. This is returned by tryEvaluateBool, /// and is used by the CFGBuilder to decide if a branch condition /// can be decided up front during CFG construction. class TryResult { @@ -402,9 +402,9 @@ private: } }; - /// TryEvaluateBool - Try and evaluate the Stmt and return 0 or 1 + /// tryEvaluateBool - Try and evaluate the Stmt and return 0 or 1 /// if we can evaluate to a known value, otherwise return -1. - TryResult TryEvaluateBool(Expr *S) { + TryResult tryEvaluateBool(Expr *S) { if (!BuildOpts.PruneTriviallyFalseEdges) return TryResult(); @@ -491,7 +491,7 @@ CFG* CFGBuilder::buildCFG(const Decl *D, Stmt* Statement, ASTContext* C, JumpTarget JT = LI->second; prependAutomaticObjDtorsWithTerminator(B, I->ScopePos, JT.ScopePos); - AddSuccessor(B, JT.Block); + addSuccessor(B, JT.Block); } // Add successors to the Indirect Goto Dispatch block (if we have one). @@ -506,7 +506,7 @@ CFG* CFGBuilder::buildCFG(const Decl *D, Stmt* Statement, ASTContext* C, // at an incomplete AST. Handle this by not registering a successor. if (LI == LabelMap.end()) continue; - AddSuccessor(B, LI->second.Block); + addSuccessor(B, LI->second.Block); } // Create an empty entry block that has no predecessors. @@ -520,7 +520,7 @@ CFG* CFGBuilder::buildCFG(const Decl *D, Stmt* Statement, ASTContext* C, CFGBlock* CFGBuilder::createBlock(bool add_successor) { CFGBlock* B = cfg->createBlock(); if (add_successor && Succ) - AddSuccessor(B, Succ); + addSuccessor(B, Succ); return B; } @@ -977,18 +977,18 @@ CFGBlock *CFGBuilder::VisitBinaryOperator(BinaryOperator *B, } // See if this is a known constant. - TryResult KnownVal = TryEvaluateBool(B->getLHS()); + TryResult KnownVal = tryEvaluateBool(B->getLHS()); if (KnownVal.isKnown() && (B->getOpcode() == BO_LOr)) KnownVal.negate(); // Now link the LHSBlock with RHSBlock. if (B->getOpcode() == BO_LOr) { - AddSuccessor(LHSBlock, KnownVal.isTrue() ? NULL : ConfluenceBlock); - AddSuccessor(LHSBlock, KnownVal.isFalse() ? NULL : RHSBlock); + addSuccessor(LHSBlock, KnownVal.isTrue() ? NULL : ConfluenceBlock); + addSuccessor(LHSBlock, KnownVal.isFalse() ? NULL : RHSBlock); } else { assert(B->getOpcode() == BO_LAnd); - AddSuccessor(LHSBlock, KnownVal.isFalse() ? NULL : RHSBlock); - AddSuccessor(LHSBlock, KnownVal.isTrue() ? NULL : ConfluenceBlock); + addSuccessor(LHSBlock, KnownVal.isFalse() ? NULL : RHSBlock); + addSuccessor(LHSBlock, KnownVal.isTrue() ? NULL : ConfluenceBlock); } // Generate the blocks for evaluating the LHS. @@ -1047,7 +1047,7 @@ CFGBlock *CFGBuilder::VisitBreakStmt(BreakStmt *B) { // AST. This means that the CFG cannot be constructed. if (BreakJumpTarget.Block) { addAutomaticObjDtors(ScopePos, BreakJumpTarget.ScopePos, B); - AddSuccessor(Block, BreakJumpTarget.Block); + addSuccessor(Block, BreakJumpTarget.Block); } else badCFG = true; @@ -1110,14 +1110,14 @@ CFGBlock *CFGBuilder::VisitCallExpr(CallExpr *C, AddStmtChoice asc) { if (NoReturn) { // Wire this to the exit block directly. - AddSuccessor(Block, &cfg->getExit()); + addSuccessor(Block, &cfg->getExit()); } if (AddEHEdge) { // Add exceptional edges. if (TryTerminatedBlock) - AddSuccessor(Block, TryTerminatedBlock); + addSuccessor(Block, TryTerminatedBlock); else - AddSuccessor(Block, &cfg->getExit()); + addSuccessor(Block, &cfg->getExit()); } return VisitChildren(C); @@ -1145,9 +1145,9 @@ CFGBlock *CFGBuilder::VisitChooseExpr(ChooseExpr *C, Block = createBlock(false); // See if this is a known constant. - const TryResult& KnownVal = TryEvaluateBool(C->getCond()); - AddSuccessor(Block, KnownVal.isFalse() ? NULL : LHSBlock); - AddSuccessor(Block, KnownVal.isTrue() ? NULL : RHSBlock); + const TryResult& KnownVal = tryEvaluateBool(C->getCond()); + addSuccessor(Block, KnownVal.isFalse() ? NULL : LHSBlock); + addSuccessor(Block, KnownVal.isTrue() ? NULL : RHSBlock); Block->setTerminator(C); return addStmt(C->getCond()); } @@ -1206,15 +1206,15 @@ CFGBlock *CFGBuilder::VisitConditionalOperator(ConditionalOperator *C, Block = createBlock(false); // See if this is a known constant. - const TryResult& KnownVal = TryEvaluateBool(C->getCond()); + const TryResult& KnownVal = tryEvaluateBool(C->getCond()); if (LHSBlock) { - AddSuccessor(Block, KnownVal.isFalse() ? NULL : LHSBlock); + addSuccessor(Block, KnownVal.isFalse() ? NULL : LHSBlock); } else { if (KnownVal.isFalse()) { // If we know the condition is false, add NULL as the successor for // the block containing the condition. In this case, the confluence // block will have just one predecessor. - AddSuccessor(Block, 0); + addSuccessor(Block, 0); assert(ConfluenceBlock->pred_size() == 1); } else { // If we have no LHS expression, add the ConfluenceBlock as a direct @@ -1223,7 +1223,7 @@ CFGBlock *CFGBuilder::VisitConditionalOperator(ConditionalOperator *C, // the RHSBlock will have been added to the succcessors already, and we // want the first predecessor to the the block containing the expression // for the case when the ternary expression evaluates to true. - AddSuccessor(Block, ConfluenceBlock); + addSuccessor(Block, ConfluenceBlock); // Note that there can possibly only be one predecessor if one of the // subexpressions resulted in calling a noreturn function. std::reverse(ConfluenceBlock->pred_begin(), @@ -1231,7 +1231,7 @@ CFGBlock *CFGBuilder::VisitConditionalOperator(ConditionalOperator *C, } } - AddSuccessor(Block, KnownVal.isTrue() ? NULL : RHSBlock); + addSuccessor(Block, KnownVal.isTrue() ? NULL : RHSBlock); Block->setTerminator(C); return addStmt(C->getCond()); } @@ -1392,7 +1392,7 @@ CFGBlock* CFGBuilder::VisitIfStmt(IfStmt* I) { // Create an empty block so we can distinguish between true and false // branches in path-sensitive analyses. ThenBlock = createBlock(false); - AddSuccessor(ThenBlock, sv.get()); + addSuccessor(ThenBlock, sv.get()); } else if (Block) { if (badCFG) return 0; @@ -1406,11 +1406,11 @@ CFGBlock* CFGBuilder::VisitIfStmt(IfStmt* I) { Block->setTerminator(I); // See if this is a known constant. - const TryResult &KnownVal = TryEvaluateBool(I->getCond()); + const TryResult &KnownVal = tryEvaluateBool(I->getCond()); // Now add the successors. - AddSuccessor(Block, KnownVal.isFalse() ? NULL : ThenBlock); - AddSuccessor(Block, KnownVal.isTrue()? NULL : ElseBlock); + addSuccessor(Block, KnownVal.isFalse() ? NULL : ThenBlock); + addSuccessor(Block, KnownVal.isTrue()? NULL : ElseBlock); // Add the condition as the last statement in the new block. This may create // new blocks as the condition may contain control-flow. Any newly created @@ -1444,7 +1444,7 @@ CFGBlock* CFGBuilder::VisitReturnStmt(ReturnStmt* R) { // The Exit block is the only successor. addAutomaticObjDtors(ScopePos, LocalScope::const_iterator(), R); - AddSuccessor(Block, &cfg->getExit()); + addSuccessor(Block, &cfg->getExit()); // Add the return statement to the block. This may create new blocks if R // contains control-flow (short-circuit operations). @@ -1495,7 +1495,7 @@ CFGBlock* CFGBuilder::VisitGotoStmt(GotoStmt* G) { else { JumpTarget JT = I->second; addAutomaticObjDtors(ScopePos, JT.ScopePos, G); - AddSuccessor(Block, JT.Block); + addSuccessor(Block, JT.Block); } return Block; @@ -1577,7 +1577,7 @@ CFGBlock* CFGBuilder::VisitForStmt(ForStmt* F) { TryResult KnownVal(true); if (F->getCond()) - KnownVal = TryEvaluateBool(F->getCond()); + KnownVal = tryEvaluateBool(F->getCond()); // Now create the loop body. { @@ -1633,12 +1633,12 @@ CFGBlock* CFGBuilder::VisitForStmt(ForStmt* F) { return 0; // This new body block is a successor to our "exit" condition block. - AddSuccessor(ExitConditionBlock, KnownVal.isFalse() ? NULL : BodyBlock); + addSuccessor(ExitConditionBlock, KnownVal.isFalse() ? NULL : BodyBlock); } // Link up the condition block with the code that follows the loop. (the // false branch). - AddSuccessor(ExitConditionBlock, KnownVal.isTrue() ? NULL : LoopSuccessor); + addSuccessor(ExitConditionBlock, KnownVal.isTrue() ? NULL : LoopSuccessor); // If the loop contains initialization, create a new block for those // statements. This block can also contain statements that precede the loop. @@ -1752,12 +1752,12 @@ CFGBlock* CFGBuilder::VisitObjCForCollectionStmt(ObjCForCollectionStmt* S) { } // This new body block is a successor to our "exit" condition block. - AddSuccessor(ExitConditionBlock, BodyBlock); + addSuccessor(ExitConditionBlock, BodyBlock); } // Link up the condition block with the code that follows the loop. // (the false branch). - AddSuccessor(ExitConditionBlock, LoopSuccessor); + addSuccessor(ExitConditionBlock, LoopSuccessor); // Now create a prologue block to contain the collection expression. Block = createBlock(); @@ -1857,7 +1857,7 @@ CFGBlock* CFGBuilder::VisitWhileStmt(WhileStmt* W) { Succ = EntryConditionBlock; // See if this is a known constant. - const TryResult& KnownVal = TryEvaluateBool(W->getCond()); + const TryResult& KnownVal = tryEvaluateBool(W->getCond()); // Process the loop body. { @@ -1901,12 +1901,12 @@ CFGBlock* CFGBuilder::VisitWhileStmt(WhileStmt* W) { } // Add the loop body entry as a successor to the condition. - AddSuccessor(ExitConditionBlock, KnownVal.isFalse() ? NULL : BodyBlock); + addSuccessor(ExitConditionBlock, KnownVal.isFalse() ? NULL : BodyBlock); } // Link up the condition block with the code that follows the loop. (the // false branch). - AddSuccessor(ExitConditionBlock, KnownVal.isTrue() ? NULL : LoopSuccessor); + addSuccessor(ExitConditionBlock, KnownVal.isTrue() ? NULL : LoopSuccessor); // There can be no more statements in the condition block since we loop back // to this block. NULL out Block to force lazy creation of another block. @@ -1936,7 +1936,7 @@ CFGBlock* CFGBuilder::VisitObjCAtThrowStmt(ObjCAtThrowStmt* S) { Block = createBlock(false); // The Exit block is the only successor. - AddSuccessor(Block, &cfg->getExit()); + addSuccessor(Block, &cfg->getExit()); // Add the statement to the block. This may create new blocks if S contains // control-flow (short-circuit operations). @@ -1953,10 +1953,10 @@ CFGBlock* CFGBuilder::VisitCXXThrowExpr(CXXThrowExpr* T) { if (TryTerminatedBlock) // The current try statement is the only successor. - AddSuccessor(Block, TryTerminatedBlock); + addSuccessor(Block, TryTerminatedBlock); else // otherwise the Exit block is the only successor. - AddSuccessor(Block, &cfg->getExit()); + addSuccessor(Block, &cfg->getExit()); // Add the statement to the block. This may create new blocks if S contains // control-flow (short-circuit operations). @@ -1999,7 +1999,7 @@ CFGBlock *CFGBuilder::VisitDoStmt(DoStmt* D) { Succ = EntryConditionBlock; // See if this is a known constant. - const TryResult &KnownVal = TryEvaluateBool(D->getCond()); + const TryResult &KnownVal = tryEvaluateBool(D->getCond()); // Process the loop body. CFGBlock* BodyBlock = NULL; @@ -2047,15 +2047,15 @@ CFGBlock *CFGBuilder::VisitDoStmt(DoStmt* D) { LoopBackBlock->setLoopTarget(D); // Add the loop body entry as a successor to the condition. - AddSuccessor(ExitConditionBlock, LoopBackBlock); + addSuccessor(ExitConditionBlock, LoopBackBlock); } else - AddSuccessor(ExitConditionBlock, NULL); + addSuccessor(ExitConditionBlock, NULL); } // Link up the condition block with the code that follows the loop. // (the false branch). - AddSuccessor(ExitConditionBlock, KnownVal.isTrue() ? NULL : LoopSuccessor); + addSuccessor(ExitConditionBlock, KnownVal.isTrue() ? NULL : LoopSuccessor); // There can be no more statements in the body block(s) since we loop back to // the body. NULL out Block to force lazy creation of another block. @@ -2080,7 +2080,7 @@ CFGBlock* CFGBuilder::VisitContinueStmt(ContinueStmt* C) { // incomplete AST. This means the CFG cannot be constructed. if (ContinueJumpTarget.Block) { addAutomaticObjDtors(ScopePos, ContinueJumpTarget.ScopePos, C); - AddSuccessor(Block, ContinueJumpTarget.Block); + addSuccessor(Block, ContinueJumpTarget.Block); } else badCFG = true; @@ -2175,7 +2175,7 @@ CFGBlock* CFGBuilder::VisitSwitchStmt(SwitchStmt* Terminator) { // If we have no "default:" case, the default transition is to the code // following the switch body. - AddSuccessor(SwitchTerminatedBlock, DefaultCaseBlock); + addSuccessor(SwitchTerminatedBlock, DefaultCaseBlock); // Add the terminator and condition in the switch block. SwitchTerminatedBlock->setTerminator(Terminator); @@ -2206,16 +2206,16 @@ CFGBlock* CFGBuilder::VisitCaseStmt(CaseStmt* CS) { // (which can blow out the stack), manually unroll and create blocks // along the way. while (isa<CaseStmt>(Sub)) { - CFGBlock *CurrentBlock = createBlock(false); - CurrentBlock->setLabel(CS); + CFGBlock *currentBlock = createBlock(false); + currentBlock->setLabel(CS); if (TopBlock) - AddSuccessor(LastBlock, CurrentBlock); + addSuccessor(LastBlock, currentBlock); else - TopBlock = CurrentBlock; + TopBlock = currentBlock; - AddSuccessor(SwitchTerminatedBlock, CurrentBlock); - LastBlock = CurrentBlock; + addSuccessor(SwitchTerminatedBlock, currentBlock); + LastBlock = currentBlock; CS = cast<CaseStmt>(Sub); Sub = CS->getSubStmt(); @@ -2238,13 +2238,13 @@ CFGBlock* CFGBuilder::VisitCaseStmt(CaseStmt* CS) { // Add this block to the list of successors for the block with the switch // statement. assert(SwitchTerminatedBlock); - AddSuccessor(SwitchTerminatedBlock, CaseBlock); + addSuccessor(SwitchTerminatedBlock, CaseBlock); // We set Block to NULL to allow lazy creation of a new block (if necessary) Block = NULL; if (TopBlock) { - AddSuccessor(LastBlock, CaseBlock); + addSuccessor(LastBlock, CaseBlock); Succ = TopBlock; } else { // This block is now the implicit successor of other blocks. @@ -2317,13 +2317,13 @@ CFGBlock *CFGBuilder::VisitCXXTryStmt(CXXTryStmt *Terminator) { return 0; // Add this block to the list of successors for the block with the try // statement. - AddSuccessor(NewTryTerminatedBlock, CatchBlock); + addSuccessor(NewTryTerminatedBlock, CatchBlock); } if (!HasCatchAll) { if (PrevTryTerminatedBlock) - AddSuccessor(NewTryTerminatedBlock, PrevTryTerminatedBlock); + addSuccessor(NewTryTerminatedBlock, PrevTryTerminatedBlock); else - AddSuccessor(NewTryTerminatedBlock, &cfg->getExit()); + addSuccessor(NewTryTerminatedBlock, &cfg->getExit()); } // The code after the try is the implicit successor. @@ -2458,7 +2458,7 @@ CFGBlock* CFGBuilder::VisitIndirectGotoStmt(IndirectGotoStmt* I) { Block = createBlock(false); Block->setTerminator(I); - AddSuccessor(Block, IBlock); + addSuccessor(Block, IBlock); return addStmt(I->getTarget()); } @@ -2543,19 +2543,19 @@ CFGBlock *CFGBuilder::VisitBinaryOperatorForTemporaryDtors(BinaryOperator *E) { ConfluenceBlock->pred_end()); // See if this is a known constant. - TryResult KnownVal = TryEvaluateBool(E->getLHS()); + TryResult KnownVal = tryEvaluateBool(E->getLHS()); if (KnownVal.isKnown() && (E->getOpcode() == BO_LOr)) KnownVal.negate(); // Link LHSBlock with RHSBlock exactly the same way as for binary operator // itself. if (E->getOpcode() == BO_LOr) { - AddSuccessor(LHSBlock, KnownVal.isTrue() ? NULL : ConfluenceBlock); - AddSuccessor(LHSBlock, KnownVal.isFalse() ? NULL : RHSBlock); + addSuccessor(LHSBlock, KnownVal.isTrue() ? NULL : ConfluenceBlock); + addSuccessor(LHSBlock, KnownVal.isFalse() ? NULL : RHSBlock); } else { assert (E->getOpcode() == BO_LAnd); - AddSuccessor(LHSBlock, KnownVal.isFalse() ? NULL : RHSBlock); - AddSuccessor(LHSBlock, KnownVal.isTrue() ? NULL : ConfluenceBlock); + addSuccessor(LHSBlock, KnownVal.isFalse() ? NULL : RHSBlock); + addSuccessor(LHSBlock, KnownVal.isTrue() ? NULL : ConfluenceBlock); } Block = LHSBlock; @@ -2634,20 +2634,20 @@ CFGBlock *CFGBuilder::VisitConditionalOperatorForTemporaryDtors( Block->setTerminator(CFGTerminator(E, true)); // See if this is a known constant. - const TryResult &KnownVal = TryEvaluateBool(E->getCond()); + const TryResult &KnownVal = tryEvaluateBool(E->getCond()); if (LHSBlock) { - AddSuccessor(Block, KnownVal.isFalse() ? NULL : LHSBlock); + addSuccessor(Block, KnownVal.isFalse() ? NULL : LHSBlock); } else if (KnownVal.isFalse()) { - AddSuccessor(Block, NULL); + addSuccessor(Block, NULL); } else { - AddSuccessor(Block, ConfluenceBlock); + addSuccessor(Block, ConfluenceBlock); std::reverse(ConfluenceBlock->pred_begin(), ConfluenceBlock->pred_end()); } if (!RHSBlock) RHSBlock = ConfluenceBlock; - AddSuccessor(Block, KnownVal.isTrue() ? NULL : RHSBlock); + addSuccessor(Block, KnownVal.isTrue() ? NULL : RHSBlock); return Block; } @@ -2826,13 +2826,13 @@ class StmtPrinterHelper : public PrinterHelper { typedef llvm::DenseMap<Decl*,std::pair<unsigned,unsigned> > DeclMapTy; StmtMapTy StmtMap; DeclMapTy DeclMap; - signed CurrentBlock; - unsigned CurrentStmt; + signed currentBlock; + unsigned currentStmt; const LangOptions &LangOpts; public: StmtPrinterHelper(const CFG* cfg, const LangOptions &LO) - : CurrentBlock(0), CurrentStmt(0), LangOpts(LO) { + : currentBlock(0), currentStmt(0), LangOpts(LO) { for (CFG::const_iterator I = cfg->begin(), E = cfg->end(); I != E; ++I ) { unsigned j = 1; for (CFGBlock::const_iterator BI = (*I)->begin(), BEnd = (*I)->end() ; @@ -2872,8 +2872,8 @@ public: virtual ~StmtPrinterHelper() {} const LangOptions &getLangOpts() const { return LangOpts; } - void setBlockID(signed i) { CurrentBlock = i; } - void setStmtID(unsigned i) { CurrentStmt = i; } + void setBlockID(signed i) { currentBlock = i; } + void setStmtID(unsigned i) { currentStmt = i; } virtual bool handledStmt(Stmt* S, llvm::raw_ostream& OS) { StmtMapTy::iterator I = StmtMap.find(S); @@ -2881,8 +2881,8 @@ public: if (I == StmtMap.end()) return false; - if (CurrentBlock >= 0 && I->second.first == (unsigned) CurrentBlock - && I->second.second == CurrentStmt) { + if (currentBlock >= 0 && I->second.first == (unsigned) currentBlock + && I->second.second == currentStmt) { return false; } @@ -2896,8 +2896,8 @@ public: if (I == DeclMap.end()) return false; - if (CurrentBlock >= 0 && I->second.first == (unsigned) CurrentBlock - && I->second.second == CurrentStmt) { + if (currentBlock >= 0 && I->second.first == (unsigned) currentBlock + && I->second.second == currentStmt) { return false; } |