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/Checker/UnreachableCodeChecker.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/Checker/UnreachableCodeChecker.cpp')
-rw-r--r-- | clang/lib/Checker/UnreachableCodeChecker.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/clang/lib/Checker/UnreachableCodeChecker.cpp b/clang/lib/Checker/UnreachableCodeChecker.cpp index 7a56c7f46b4..12d13073b8c 100644 --- a/clang/lib/Checker/UnreachableCodeChecker.cpp +++ b/clang/lib/Checker/UnreachableCodeChecker.cpp @@ -116,10 +116,12 @@ void UnreachableCodeChecker::VisitEndAnalysis(ExplodedGraph &G, // FIXME: This should be extended to include other unreachable markers, // such as llvm_unreachable. if (!CB->empty()) { - const Stmt *First = CB->front(); - if (const CallExpr *CE = dyn_cast<CallExpr>(First)) { - if (CE->isBuiltinCall(Ctx) == Builtin::BI__builtin_unreachable) - continue; + CFGElement First = CB->front(); + if (CFGStmt S = First.getAs<CFGStmt>()) { + if (const CallExpr *CE = dyn_cast<CallExpr>(S.getStmt())) { + if (CE->isBuiltinCall(Ctx) == Builtin::BI__builtin_unreachable) + continue; + } } } @@ -173,9 +175,11 @@ void UnreachableCodeChecker::FindUnreachableEntryPoints(const CFGBlock *CB) { // Find the Stmt* in a CFGBlock for reporting a warning const Stmt *UnreachableCodeChecker::getUnreachableStmt(const CFGBlock *CB) { - if (CB->size() > 0) - return CB->front().getStmt(); - else if (const Stmt *S = CB->getTerminator()) + for (CFGBlock::const_iterator I = CB->begin(), E = CB->end(); I != E; ++I) { + if (CFGStmt S = I->getAs<CFGStmt>()) + return S; + } + if (const Stmt *S = CB->getTerminator()) return S; else return 0; |