[cfe-commits] r163409 - /cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp

Jordan Rose jordan_rose at apple.com
Fri Sep 7 12:48:09 PDT 2012


Author: jrose
Date: Fri Sep  7 14:48:09 2012
New Revision: 163409

URL: http://llvm.org/viewvc/llvm-project?rev=163409&view=rev
Log:
[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.

Modified:
    cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp?rev=163409&r1=163408&r2=163409&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp Fri Sep  7 14:48:09 2012
@@ -514,10 +514,9 @@
     return;
   }
 
-  CFGElement Elem = (*Block)[Idx];
-  const CFGStmt *CS = Elem.getAs<CFGStmt>();
-  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<CFGStmt>((*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





More information about the cfe-commits mailing list