From: Jordan Rose Date: Fri, 7 Sep 2012 19:48:09 +0000 (+0000) Subject: [analyzer] Use cast<> instead of getAs<> for a CFGElement known to be a CFGStmt. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9198c71a626e2f0d29d92152832f3e80f4af59b3;p=clang [analyzer] Use cast<> instead of getAs<> for a CFGElement known to be a CFGStmt. When adding the next statement to the CoreEngine's work list, we take care of all the special cases first. We certainly shouldn't be building PostStmts with null statements (the diagnostics machinery assumes such StmtPoints do not exist), and we should find out sooner if we're missing a special case. A refinement of r163402 that should help prevent further issues like PR13760. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163409 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Core/CoreEngine.cpp b/lib/StaticAnalyzer/Core/CoreEngine.cpp index 84d2cc6545..e7b406604f 100644 --- a/lib/StaticAnalyzer/Core/CoreEngine.cpp +++ b/lib/StaticAnalyzer/Core/CoreEngine.cpp @@ -514,10 +514,9 @@ void CoreEngine::enqueueStmtNode(ExplodedNode *N, return; } - CFGElement Elem = (*Block)[Idx]; - const CFGStmt *CS = Elem.getAs(); - const Stmt *St = CS ? CS->getStmt() : 0; - PostStmt Loc(St, N->getLocationContext()); + // At this point, we know we're processing a normal statement. + CFGStmt CS = cast((*Block)[Idx]); + PostStmt Loc(CS.getStmt(), N->getLocationContext()); if (Loc == N->getLocation()) { // Note: 'N' should be a fresh node because otherwise it shouldn't be