[PATCH] D37963: [analyzer] PthreadLock: Don't track dead regions.
Artem Dergachev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 17 13:39:04 PDT 2017
NoQ created this revision.
Standard boilerplate: stop tracking mutex state when the mutex dies as a region.
Clean up the destroyed symbol cleanup code a tiny bit. Note that this code is unaffected by the zombie symbol bug because whenever we need to take action, constraint manager is bound to mark the symbol as maybe-dead for us.
No tests because this is merely an optimization.
https://reviews.llvm.org/D37963
Files:
lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
Index: lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
+++ lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
@@ -556,19 +556,20 @@
CheckerContext &C) const {
ProgramStateRef State = C.getState();
- // TODO: Clean LockMap when a mutex region dies.
-
- DestroyRetValTy TrackedSymbols = State->get<DestroyRetVal>();
- for (DestroyRetValTy::iterator I = TrackedSymbols.begin(),
- E = TrackedSymbols.end();
- I != E; ++I) {
- const SymbolRef Sym = I->second;
- const MemRegion *lockR = I->first;
- bool IsSymDead = SymReaper.isDead(Sym);
- // Remove the dead symbol from the return value symbols map.
- if (IsSymDead)
- State = resolvePossiblyDestroyedMutex(State, lockR, &Sym);
+ for (auto I : State->get<DestroyRetVal>()) {
+ // Once the return value symbol dies, no more checks can be performed
+ // against it. See if the return value was checked before this point.
+ // This would remove the symbol from the map as well.
+ if (SymReaper.isDead(I.second))
+ State = resolvePossiblyDestroyedMutex(State, I.first, &I.second);
}
+
+ for (auto I : State->get<LockMap>()) {
+ // Stop tracking dead mutex regions as well.
+ if (!SymReaper.isLiveRegion(I.first))
+ State = State->remove<LockMap>(I.first);
+ }
+
C.addTransition(State);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37963.115587.patch
Type: text/x-patch
Size: 1506 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170917/f44cbe22/attachment-0001.bin>
More information about the cfe-commits
mailing list