================
@@ -532,15 +533,18 @@ void PthreadLockChecker::ReleaseLockAux(const CallEvent
&Call,
LockSetTy LS = state->get<LockSet>();
if (!LS.isEmpty()) {
- const MemRegion *firstLockR = LS.getHead();
- if (firstLockR != lockR) {
+ if (WarnOnLockOrderReversal && LS.getHead() != lockR) {
reportBug(C, BT_lor, MtxExpr, CheckKind,
"This was not the most recently acquired lock. Possible lock "
"order reversal");
return;
}
- // Record that the lock was released.
- state = state->set<LockSet>(LS.getTail());
+ auto &Factory = state->get_context<LockSet>();
+ llvm::ImmutableList<const MemRegion *> NewLS = Factory.getEmptyList();
+ for (auto I = LS.begin(), E = LS.end(); I != E; ++I)
+ if (*I != lockR)
+ NewLS = Factory.add(*I, NewLS);
+ state = state->set<LockSet>(NewLS);
----------------
steakhal wrote:
You should be able to express this like this, once #202580 has landed:
```suggestion
auto &Factory = state->get_context<LockSet>();
llvm::ImmutableList<const MemRegion *> NewLS = Factory.getEmptyList();
for (const MemRegion *LockReg :
make_filter_range(state->get<LockSet>(), llvm::not_equal_to(lockR))) {
NewLS = Factory.add(LockReg, NewLS);
}
state = state->set<LockSet>(NewLS);
```
https://github.com/llvm/llvm-project/pull/202452
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits