[PATCH] D104261: Thread safety analysis: Always warn when dropping locks on back edges
Aaron Puchert via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 25 08:56:29 PDT 2021
aaronpuchert added inline comments.
================
Comment at: clang/lib/Analysis/ThreadSafety.cpp:868
ThreadSafetyHandler &Handler) const override {
- if (!managed() && !asserted() && !negative() && !isUniversal()) {
+ if (!asserted() && !negative() && !isUniversal()) {
Handler.handleMutexHeldEndOfScope("mutex", toString(), loc(), JoinLoc,
----------------
aaronpuchert wrote:
> One might ask: what about asserted capabilities? I plan to introduce a warning when they are released, because that can't be consistent, and then they can't disappear on back edges without warning.
>
> For negative capabilities we'd presumably see a warning for the "positive" capability instead.
>
> Not sure how universal capabilities are typically used. Presumably one could release such a capability in a loop? Then on the other hand, code using such capabilities is probably not very interested in false negatives.
> For negative capabilities we'd presumably see a warning for the "positive" capability instead.
No, because a back edge is missing a positive capability when I'm unlocking in a loop, whereas it would be missing a negative capability when I'm locking in a loop.
But we probably want to warn about this only when `-Wthread-safety-negative` is active.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104261/new/
https://reviews.llvm.org/D104261
More information about the cfe-commits
mailing list