[clang] [clang] WIP: Warn on mismatched RequiresCapability attributes (PR #67520)

Aaron Puchert via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 5 13:42:23 PDT 2024


aaronpuchert wrote:

> > That might not be enough. A function might not be used (or even referenced) in the TU that defines it, but only in other TUs. But it would certainly catch a number of issues already.
> 
> Right, though catching that ends up being pretty impossible. The most you could do is determine that the declaration in the defining TU doesn't have it, but not that other forward declarations not visible could catch it.

Correct, these are all just heuristics. Functions are not typically "forward-declared", so they often have a canonical public declaration. But it is of course possible to declare functions in multiple header files.

> Unfortunately, unless an attribute contributes to mangling (which, should we consider that?) there is no real way to catch every case.

No, I think we don't want mangling. One of the design goals of Thread Safety Analysis was that the attributes should be "erasable", so that they can be dropped for compilers that don't understand them. (See for example https://static.googleusercontent.com/media/research.google.com/en/us/pubs/archive/42958.pdf.)

https://github.com/llvm/llvm-project/pull/67520


More information about the cfe-commits mailing list