[clang] [clang][ThreadSafety] Warn when constructor is trylock (PR #95290)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 18 05:43:43 PDT 2024
AaronBallman wrote:
> * A handful of functions in the parsing tests return `void` and yet are annotated as trylock functions. I don't believe this is a valid use case. What does `EXCLUSIVE_TRYLOCK_FUNCTION` mean when it's impossible to return a value? I think the solution is to just change `void` to `bool` for trylock functions in tests.
Agreed
> * This next failure is tricker... I was really surprised to see a trylock method that returns a pointer! Confusingly, the "success" parameter to the attribute is `1`. I think the semantics work out so that returning a non-`nullptr` value indicates successful mutex acquisition.
Oof, that's an odd one, but I can see the logic behind supporting it. I think it would be good for us to call out support for this explicitly in the documentation.
> I'm not quite sure what to do here. Maybe we should be lenient and only enforce that the return type is boolean, integer, or pointer?
We definitely need to support integer return types because of how often integers or enumerations are used to indicate errors. I think we should continue to support the pointer behavior given that it works already today.
https://github.com/llvm/llvm-project/pull/95290
More information about the cfe-commits
mailing list