[clang] [clang] WIP: Warn on mismatched RequiresCapability attributes (PR #67520)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 5 10:47:29 PDT 2024
erichkeane 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.
Unfortunately, unless an attribute contributes to mangling (which, should we consider that?) there is no real way to catch every case.
Perhaps we could make this a non-inheritable attribute as well, which should catch at least the "added in future declarations". I think we in a few places we actually DO disallow adding attributes to not-the-first-declaration (which could be done in 'merge', but even just SemaDeclAttr could figure that out), but its not particularly perfect.
So in summary:
-This could/should be caught in Sema, either MergeDeclAttrs or the SemaDeclAttr handling
-We can't catch cross-TU issues here unless we make `RequiresCapability` change mangling.
https://github.com/llvm/llvm-project/pull/67520
More information about the cfe-commits
mailing list