diff options
Diffstat (limited to 'lib/Analysis')
-rw-r--r-- | lib/Analysis/CFG.cpp | 38 | ||||
-rw-r--r-- | lib/Analysis/CFGStmtMap.cpp | 4 | ||||
-rw-r--r-- | lib/Analysis/LiveVariables.cpp | 10 | ||||
-rw-r--r-- | lib/Analysis/ReachableCode.cpp | 4 | ||||
-rw-r--r-- | lib/Analysis/ThreadSafety.cpp | 12 | ||||
-rw-r--r-- | lib/Analysis/UninitializedValues.cpp | 5 |
6 files changed, 37 insertions, 36 deletions
diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp index 8754fe86a8..4d20467a79 100644 --- a/lib/Analysis/CFG.cpp +++ b/lib/Analysis/CFG.cpp @@ -3332,7 +3332,6 @@ CFG* CFG::buildCFG(const Decl *D, Stmt *Statement, ASTContext *C, const CXXDestructorDecl * CFGImplicitDtor::getDestructorDecl(ASTContext &astContext) const { switch (getKind()) { - case CFGElement::Invalid: case CFGElement::Statement: case CFGElement::Initializer: llvm_unreachable("getDestructorDecl should only be used with " @@ -3406,8 +3405,8 @@ static BlkExprMapTy* PopulateBlkExprMap(CFG& cfg) { for (CFG::iterator I=cfg.begin(), E=cfg.end(); I != E; ++I) for (CFGBlock::iterator BI=(*I)->begin(), EI=(*I)->end(); BI != EI; ++BI) - if (CFGStmt S = BI->getAs<CFGStmt>()) - FindSubExprAssignments(S.getStmt(), SubExprAssignments); + if (Optional<CFGStmt> S = BI->getAs<CFGStmt>()) + FindSubExprAssignments(S->getStmt(), SubExprAssignments); for (CFG::iterator I=cfg.begin(), E=cfg.end(); I != E; ++I) { @@ -3415,10 +3414,10 @@ static BlkExprMapTy* PopulateBlkExprMap(CFG& cfg) { // block-level that are block-level expressions. for (CFGBlock::iterator BI=(*I)->begin(), EI=(*I)->end(); BI != EI; ++BI) { - CFGStmt CS = BI->getAs<CFGStmt>(); + Optional<CFGStmt> CS = BI->getAs<CFGStmt>(); if (!CS) continue; - if (const Expr *Exp = dyn_cast<Expr>(CS.getStmt())) { + if (const Expr *Exp = dyn_cast<Expr>(CS->getStmt())) { assert((Exp->IgnoreParens() == Exp) && "No parens on block-level exps"); if (const BinaryOperator* B = dyn_cast<BinaryOperator>(Exp)) { @@ -3531,8 +3530,8 @@ public: unsigned j = 1; for (CFGBlock::const_iterator BI = (*I)->begin(), BEnd = (*I)->end() ; BI != BEnd; ++BI, ++j ) { - if (CFGStmt SE = BI->getAs<CFGStmt>()) { - const Stmt *stmt= SE.getStmt(); + if (Optional<CFGStmt> SE = BI->getAs<CFGStmt>()) { + const Stmt *stmt= SE->getStmt(); std::pair<unsigned, unsigned> P((*I)->getBlockID(), j); StmtMap[stmt] = P; @@ -3721,8 +3720,8 @@ public: static void print_elem(raw_ostream &OS, StmtPrinterHelper* Helper, const CFGElement &E) { - if (CFGStmt CS = E.getAs<CFGStmt>()) { - const Stmt *S = CS.getStmt(); + if (Optional<CFGStmt> CS = E.getAs<CFGStmt>()) { + const Stmt *S = CS->getStmt(); if (Helper) { @@ -3769,8 +3768,8 @@ static void print_elem(raw_ostream &OS, StmtPrinterHelper* Helper, if (isa<Expr>(S)) OS << '\n'; - } else if (CFGInitializer IE = E.getAs<CFGInitializer>()) { - const CXXCtorInitializer *I = IE.getInitializer(); + } else if (Optional<CFGInitializer> IE = E.getAs<CFGInitializer>()) { + const CXXCtorInitializer *I = IE->getInitializer(); if (I->isBaseInitializer()) OS << I->getBaseClass()->getAsCXXRecordDecl()->getName(); else OS << I->getAnyMember()->getName(); @@ -3784,8 +3783,9 @@ static void print_elem(raw_ostream &OS, StmtPrinterHelper* Helper, OS << " (Base initializer)\n"; else OS << " (Member initializer)\n"; - } else if (CFGAutomaticObjDtor DE = E.getAs<CFGAutomaticObjDtor>()){ - const VarDecl *VD = DE.getVarDecl(); + } else if (Optional<CFGAutomaticObjDtor> DE = + E.getAs<CFGAutomaticObjDtor>()) { + const VarDecl *VD = DE->getVarDecl(); Helper->handleDecl(VD, OS); const Type* T = VD->getType().getTypePtr(); @@ -3796,20 +3796,20 @@ static void print_elem(raw_ostream &OS, StmtPrinterHelper* Helper, OS << ".~" << T->getAsCXXRecordDecl()->getName().str() << "()"; OS << " (Implicit destructor)\n"; - } else if (CFGBaseDtor BE = E.getAs<CFGBaseDtor>()) { - const CXXBaseSpecifier *BS = BE.getBaseSpecifier(); + } else if (Optional<CFGBaseDtor> BE = E.getAs<CFGBaseDtor>()) { + const CXXBaseSpecifier *BS = BE->getBaseSpecifier(); OS << "~" << BS->getType()->getAsCXXRecordDecl()->getName() << "()"; OS << " (Base object destructor)\n"; - } else if (CFGMemberDtor ME = E.getAs<CFGMemberDtor>()) { - const FieldDecl *FD = ME.getFieldDecl(); + } else if (Optional<CFGMemberDtor> ME = E.getAs<CFGMemberDtor>()) { + const FieldDecl *FD = ME->getFieldDecl(); const Type *T = FD->getType()->getBaseElementTypeUnsafe(); OS << "this->" << FD->getName(); OS << ".~" << T->getAsCXXRecordDecl()->getName() << "()"; OS << " (Member object destructor)\n"; - } else if (CFGTemporaryDtor TE = E.getAs<CFGTemporaryDtor>()) { - const CXXBindTemporaryExpr *BT = TE.getBindTemporaryExpr(); + } else if (Optional<CFGTemporaryDtor> TE = E.getAs<CFGTemporaryDtor>()) { + const CXXBindTemporaryExpr *BT = TE->getBindTemporaryExpr(); OS << "~" << BT->getType()->getAsCXXRecordDecl()->getName() << "()"; OS << " (Temporary object destructor)\n"; } diff --git a/lib/Analysis/CFGStmtMap.cpp b/lib/Analysis/CFGStmtMap.cpp index 7daeef9216..87c2f5bdc1 100644 --- a/lib/Analysis/CFGStmtMap.cpp +++ b/lib/Analysis/CFGStmtMap.cpp @@ -50,11 +50,11 @@ static void Accumulate(SMap &SM, CFGBlock *B) { // First walk the block-level expressions. for (CFGBlock::iterator I = B->begin(), E = B->end(); I != E; ++I) { const CFGElement &CE = *I; - CFGStmt CS = CE.getAs<CFGStmt>(); + Optional<CFGStmt> CS = CE.getAs<CFGStmt>(); if (!CS) continue; - CFGBlock *&Entry = SM[CS.getStmt()]; + CFGBlock *&Entry = SM[CS->getStmt()]; // If 'Entry' is already initialized (e.g., a terminator was already), // skip. if (Entry) diff --git a/lib/Analysis/LiveVariables.cpp b/lib/Analysis/LiveVariables.cpp index 519d5288b8..b43892a309 100644 --- a/lib/Analysis/LiveVariables.cpp +++ b/lib/Analysis/LiveVariables.cpp @@ -474,8 +474,9 @@ LiveVariablesImpl::runOnBlock(const CFGBlock *block, ei = block->rend(); it != ei; ++it) { const CFGElement &elem = *it; - if (CFGAutomaticObjDtor Dtor = elem.getAs<CFGAutomaticObjDtor>()){ - val.liveDecls = DSetFact.add(val.liveDecls, Dtor.getVarDecl()); + if (Optional<CFGAutomaticObjDtor> Dtor = + elem.getAs<CFGAutomaticObjDtor>()) { + val.liveDecls = DSetFact.add(val.liveDecls, Dtor->getVarDecl()); continue; } @@ -534,8 +535,9 @@ LiveVariables::computeLiveness(AnalysisDeclContext &AC, if (killAtAssign) for (CFGBlock::const_iterator bi = block->begin(), be = block->end(); bi != be; ++bi) { - if (CFGStmt cs = bi->getAs<CFGStmt>()) { - if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(cs.getStmt())) { + if (Optional<CFGStmt> cs = bi->getAs<CFGStmt>()) { + if (const BinaryOperator *BO = + dyn_cast<BinaryOperator>(cs->getStmt())) { if (BO->getOpcode() == BO_Assign) { if (const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(BO->getLHS()->IgnoreParens())) { diff --git a/lib/Analysis/ReachableCode.cpp b/lib/Analysis/ReachableCode.cpp index f85e2dee52..a90aebbe28 100644 --- a/lib/Analysis/ReachableCode.cpp +++ b/lib/Analysis/ReachableCode.cpp @@ -95,8 +95,8 @@ static bool isValidDeadStmt(const Stmt *S) { const Stmt *DeadCodeScan::findDeadCode(const clang::CFGBlock *Block) { for (CFGBlock::const_iterator I = Block->begin(), E = Block->end(); I!=E; ++I) - if (CFGStmt CS = I->getAs<CFGStmt>()) { - const Stmt *S = CS.getStmt(); + if (Optional<CFGStmt> CS = I->getAs<CFGStmt>()) { + const Stmt *S = CS->getStmt(); if (isValidDeadStmt(S)) return S; } diff --git a/lib/Analysis/ThreadSafety.cpp b/lib/Analysis/ThreadSafety.cpp index 2e3abc07b7..7bb54d6ad3 100644 --- a/lib/Analysis/ThreadSafety.cpp +++ b/lib/Analysis/ThreadSafety.cpp @@ -1397,8 +1397,8 @@ static void findBlockLocations(CFG *CFGraph, for (CFGBlock::const_reverse_iterator BI = CurrBlock->rbegin(), BE = CurrBlock->rend(); BI != BE; ++BI) { // FIXME: Handle other CFGElement kinds. - if (CFGStmt CS = BI->getAs<CFGStmt>()) { - CurrBlockInfo->ExitLoc = CS.getStmt()->getLocStart(); + if (Optional<CFGStmt> CS = BI->getAs<CFGStmt>()) { + CurrBlockInfo->ExitLoc = CS->getStmt()->getLocStart(); break; } } @@ -1410,8 +1410,8 @@ static void findBlockLocations(CFG *CFGraph, for (CFGBlock::const_iterator BI = CurrBlock->begin(), BE = CurrBlock->end(); BI != BE; ++BI) { // FIXME: Handle other CFGElement kinds. - if (CFGStmt CS = BI->getAs<CFGStmt>()) { - CurrBlockInfo->EntryLoc = CS.getStmt()->getLocStart(); + if (Optional<CFGStmt> CS = BI->getAs<CFGStmt>()) { + CurrBlockInfo->EntryLoc = CS->getStmt()->getLocStart(); break; } } @@ -2234,8 +2234,8 @@ inline bool neverReturns(const CFGBlock* B) { return false; CFGElement Last = B->back(); - if (CFGStmt S = Last.getAs<CFGStmt>()) { - if (isa<CXXThrowExpr>(S.getStmt())) + if (Optional<CFGStmt> S = Last.getAs<CFGStmt>()) { + if (isa<CXXThrowExpr>(S->getStmt())) return true; } return false; diff --git a/lib/Analysis/UninitializedValues.cpp b/lib/Analysis/UninitializedValues.cpp index 022bb7d513..730aa6ba21 100644 --- a/lib/Analysis/UninitializedValues.cpp +++ b/lib/Analysis/UninitializedValues.cpp @@ -746,9 +746,8 @@ static bool runOnBlock(const CFGBlock *block, const CFG &cfg, TransferFunctions tf(vals, cfg, block, ac, classification, handler); for (CFGBlock::const_iterator I = block->begin(), E = block->end(); I != E; ++I) { - if (CFGStmt cs = I->getAs<CFGStmt>()) { - tf.Visit(const_cast<Stmt*>(cs.getStmt())); - } + if (Optional<CFGStmt> cs = I->getAs<CFGStmt>()) + tf.Visit(const_cast<Stmt*>(cs->getStmt())); } return vals.updateValueVectorWithScratch(block); } |