diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2010-09-16 01:25:47 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2010-09-16 01:25:47 +0000 |
commit | 2cd7a78c760d1c8052fed67317de2abf2844c5ef (patch) | |
tree | 00cd6b740cd87f2ef4fe0ccd5c8478ef6bfa100c /clang/lib/Analysis/CFG.cpp | |
parent | 7ce490c6b5670448b6ee95254d054e8fcf34441f (diff) | |
download | bcm5719-llvm-2cd7a78c760d1c8052fed67317de2abf2844c5ef.tar.gz bcm5719-llvm-2cd7a78c760d1c8052fed67317de2abf2844c5ef.zip |
Introduce new CFGElement hierarchy to support C++ CFG, based on Marcin's patch
and discussions with Ted and Jordy.
llvm-svn: 114056
Diffstat (limited to 'clang/lib/Analysis/CFG.cpp')
-rw-r--r-- | clang/lib/Analysis/CFG.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index cc3a3888626..963d45dd98f 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -1846,15 +1846,19 @@ 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) - FindSubExprAssignments(*BI, SubExprAssignments); + if (CFGStmt S = BI->getAs<CFGStmt>()) + FindSubExprAssignments(S, SubExprAssignments); for (CFG::iterator I=cfg.begin(), E=cfg.end(); I != E; ++I) { // Iterate over the statements again on identify the Expr* and Stmt* at the // block-level that are block-level expressions. - for (CFGBlock::iterator BI=(*I)->begin(), EI=(*I)->end(); BI != EI; ++BI) - if (Expr* Exp = dyn_cast<Expr>(*BI)) { + for (CFGBlock::iterator BI=(*I)->begin(), EI=(*I)->end(); BI != EI; ++BI) { + CFGStmt CS = BI->getAs<CFGStmt>(); + if (!CS.isValid()) + continue; + if (Expr* Exp = dyn_cast<Expr>(CS.getStmt())) { if (BinaryOperator* B = dyn_cast<BinaryOperator>(Exp)) { // Assignment expressions that are not nested within another @@ -1875,6 +1879,7 @@ static BlkExprMapTy* PopulateBlkExprMap(CFG& cfg) { unsigned x = M->size(); (*M)[Exp] = x; } + } // Look at terminators. The condition is a block-level expression. @@ -1959,9 +1964,13 @@ public: 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() ; - BI != BEnd; ++BI, ++j ) - StmtMap[*BI] = std::make_pair((*I)->getBlockID(),j); + BI != BEnd; ++BI, ++j ) { + CFGStmt CS = BI->getAs<CFGStmt>(); + if (!CS.isValid()) + continue; + StmtMap[CS] = std::make_pair((*I)->getBlockID(),j); } + } } virtual ~StmtPrinterHelper() {} @@ -2090,7 +2099,10 @@ public: static void print_stmt(llvm::raw_ostream &OS, StmtPrinterHelper* Helper, const CFGElement &E) { - Stmt *S = E; + CFGStmt CS = E.getAs<CFGStmt>(); + if (!CS) + return; + Stmt *S = CS.getStmt(); if (Helper) { // special printing for statement-expressions. |