[cfe-commits] r141045 - /cfe/trunk/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp

Anna Zaks ganna at apple.com
Mon Oct 3 16:07:13 PDT 2011


Author: zaks
Date: Mon Oct  3 18:07:13 2011
New Revision: 141045

URL: http://llvm.org/viewvc/llvm-project?rev=141045&view=rev
Log:
[analyzer] Remove redundant state (AnalysisContext pointer for every BinaryOperator tracked) from IdempotentOperationChecker.

Modified:
    cfe/trunk/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp?rev=141045&r1=141044&r2=141045&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp Mon Oct  3 18:07:13 2011
@@ -96,10 +96,9 @@
 
   // Hash table and related data structures
   struct BinaryOperatorData {
-    BinaryOperatorData() : assumption(Possible), analysisContext(0) {}
+    BinaryOperatorData() : assumption(Possible) {}
 
     Assumption assumption;
-    AnalysisContext *analysisContext;
     ExplodedNodeSet explodedNodes; // Set of ExplodedNodes that refer to a
                                    // BinaryOperator
   };
@@ -118,7 +117,6 @@
   BinaryOperatorData &Data = hash[B];
   Assumption &A = Data.assumption;
   AnalysisContext *AC = C.getCurrentAnalysisContext();
-  Data.analysisContext = AC;
 
   // If we already have visited this node on a path that does not contain an
   // idempotent operation, return immediately.
@@ -351,9 +349,14 @@
     // Unpack the hash contents
     const BinaryOperatorData &Data = i->second;
     const Assumption &A = Data.assumption;
-    AnalysisContext *AC = Data.analysisContext;
     const ExplodedNodeSet &ES = Data.explodedNodes;
 
+    // If there are no nodes accosted with the expression, nothing to report.
+    // FIXME: This is possible because the checker does part of processing in
+    // checkPreStmt and part in checkPostStmt.
+    if (ES.begin() == ES.end())
+      continue;
+
     const BinaryOperator *B = i->first;
 
     if (A == Impossible)
@@ -363,6 +366,8 @@
     // warning
     if (Eng.hasWorkRemaining()) {
       // If we can trace back
+      AnalysisContext *AC = (*ES.begin())->getLocationContext()
+                                         ->getAnalysisContext();
       if (!pathWasCompletelyAnalyzed(AC,
                                      AC->getCFGStmtMap()->getBlock(B),
                                      Eng.getCoreEngine()))





More information about the cfe-commits mailing list