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 | b36cd3e1757fb4fcd9509f35558c847b04bef35f (patch) | |
tree | bd1aa08c903a1b5007a6dfd2c892617d20c45b47 /lib/Checker | |
parent | 6dbcaf3849709e271ffad5974150a6adbbfbb064 (diff) |
Introduce new CFGElement hierarchy to support C++ CFG, based on Marcin's patch
and discussions with Ted and Jordy.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114056 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Checker')
-rw-r--r-- | lib/Checker/BugReporter.cpp | 16 | ||||
-rw-r--r-- | lib/Checker/GRExprEngine.cpp | 4 | ||||
-rw-r--r-- | lib/Checker/UnreachableCodeChecker.cpp | 18 |
3 files changed, 21 insertions, 17 deletions
diff --git a/lib/Checker/BugReporter.cpp b/lib/Checker/BugReporter.cpp index 5043d90526..a3f4f032a2 100644 --- a/lib/Checker/BugReporter.cpp +++ b/lib/Checker/BugReporter.cpp @@ -1165,15 +1165,15 @@ static void GenerateExtensivePathDiagnostic(PathDiagnostic& PD, } if (const BlockEntrance *BE = dyn_cast<BlockEntrance>(&P)) { - if (const Stmt* S = BE->getFirstStmt()) { - if (IsControlFlowExpr(S)) { - // Add the proper context for '&&', '||', and '?'. - EB.addContext(S); - } - else - EB.addExtendedContext(PDB.getEnclosingStmtLocation(S).asStmt()); + if (CFGStmt S = BE->getFirstElement().getAs<CFGStmt>()) { + if (IsControlFlowExpr(S)) { + // Add the proper context for '&&', '||', and '?'. + EB.addContext(S); + } + else + EB.addExtendedContext(PDB.getEnclosingStmtLocation(S).asStmt()); } - + break; } } while (0); diff --git a/lib/Checker/GRExprEngine.cpp b/lib/Checker/GRExprEngine.cpp index bead4e1c1a..e01c645a89 100644 --- a/lib/Checker/GRExprEngine.cpp +++ b/lib/Checker/GRExprEngine.cpp @@ -634,7 +634,7 @@ void GRExprEngine::ProcessEndWorklist(bool hasWorkRemaining) { } void GRExprEngine::ProcessStmt(const CFGElement CE,GRStmtNodeBuilder& builder) { - CurrentStmt = CE.getStmt(); + CurrentStmt = CE.getAs<CFGStmt>(); PrettyStackTraceLoc CrashInfo(getContext().getSourceManager(), CurrentStmt->getLocStart(), "Error evaluating statement"); @@ -721,7 +721,7 @@ void GRExprEngine::ProcessStmt(const CFGElement CE,GRStmtNodeBuilder& builder) { Builder->SetCleanedState(*I == EntryNode ? CleanedState : GetState(*I)); // Visit the statement. - if (CE.asLValue()) + if (CE.getAs<CFGStmt>().asLValue()) VisitLValue(cast<Expr>(CurrentStmt), *I, Dst); else Visit(CurrentStmt, *I, Dst); diff --git a/lib/Checker/UnreachableCodeChecker.cpp b/lib/Checker/UnreachableCodeChecker.cpp index 7a56c7f46b..12d13073b8 100644 --- a/lib/Checker/UnreachableCodeChecker.cpp +++ b/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; |