[clang] [clang][analyzer] Add note tags to alpha.unix.BlockInCriticalSection (PR #80029)
Balázs Kéri via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 7 23:58:14 PST 2024
================
@@ -57,6 +61,12 @@ class BlockInCriticalSectionChecker : public Checker<check::PostCall> {
const CallEvent &call,
CheckerContext &C) const;
+ CritSectionMarker getCriticalSectionMarker(const CallEvent &Call,
+ CheckerContext &C) const;
+ const NoteTag *
+ createCriticalSectionNote(const CritSectionMarker &CriticalSectionBegin,
+ CheckerContext &C) const;
----------------
balazske wrote:
I do not know if it is sufficient to store the set of all found lock calls until the last unlock happens. Probably in the following situation it does not work:
```
std::mutex m, n, k;
m.lock();
n.lock();
n.unlock();
k.lock();
k.unlock();
sleep(1);
m.unlock();
```
It looks better to store all locked mutex objects somehow (not the lock calls), and remove one at unlock. Then the mutex counter is not needed.
https://github.com/llvm/llvm-project/pull/80029
More information about the cfe-commits
mailing list