[PATCH] D54013: [analyzer] NFC: MallocChecker: Avoid redundant transitions.

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 29 19:55:47 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rC347955: [analyzer] MallocChecker: Avoid redundant transitions. (authored by dergachev, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D54013?vs=172629&id=176030#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54013/new/

https://reviews.llvm.org/D54013

Files:
  lib/StaticAnalyzer/Checkers/MallocChecker.cpp


Index: lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -2346,9 +2346,10 @@
                                      CheckerContext &C) const
 {
   ProgramStateRef state = C.getState();
-  RegionStateTy RS = state->get<RegionState>();
+  RegionStateTy OldRS = state->get<RegionState>();
   RegionStateTy::Factory &F = state->get_context<RegionState>();
 
+  RegionStateTy RS = OldRS;
   SmallVector<SymbolRef, 2> Errors;
   for (RegionStateTy::iterator I = RS.begin(), E = RS.end(); I != E; ++I) {
     if (SymReaper.isDead(I->first)) {
@@ -2356,10 +2357,18 @@
         Errors.push_back(I->first);
       // Remove the dead symbol from the map.
       RS = F.remove(RS, I->first);
-
     }
   }
 
+  if (RS == OldRS) {
+    // We shouldn't have touched other maps yet.
+    assert(state->get<ReallocPairs>() ==
+           C.getState()->get<ReallocPairs>());
+    assert(state->get<FreeReturnValue>() ==
+           C.getState()->get<FreeReturnValue>());
+    return;
+  }
+
   // Cleanup the Realloc Pairs Map.
   ReallocPairsTy RP = state->get<ReallocPairs>();
   for (ReallocPairsTy::iterator I = RP.begin(), E = RP.end(); I != E; ++I) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54013.176030.patch
Type: text/x-patch
Size: 1306 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181130/e245c682/attachment.bin>


More information about the cfe-commits mailing list