theuni wrote:

> > On a related note, do we emit `-Wthread-safety-negative` for reentrant 
> > locks? I don't remember that we carved out an exception for that, and we 
> > probably should.
> 
> We do - and it's deliberate on my part as I've been trying to indicate that 
> there might be valid use cases for that. While conceptually contradictory, 
> there might be cases where developers want to ensure a reentrant mutex is NOT 
> held before entering a function.

Chiming in here with a use-case...

My software currently contains a nasty global recursive lock that we hope to 
(over a long period of time, likely years) convert to non-recursive.

In the meantime, and during the refactor, it's helpful to be able to mark some 
functions as `EXCLUSIVE_LOCKS_REQUIRED(!recursive_mut)` even though technically 
it wouldn't be a problem.

Ideally, that would even "convert" the lock, as far as the annotations go, to 
non-recursive. That way, from that point on, functions further down the 
call-stack could no longer double-lock. Though, I suppose that's arguably a 
different feature altogether.

https://github.com/llvm/llvm-project/pull/141599
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to