[clang] [clang][TSA] Make RequiresCapability a DeclOrType attribute (PR #67095)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 11 10:47:01 PDT 2023


Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>
Message-ID:
In-Reply-To: <llvm/llvm-project/pull/67095/clang at github.com>


================
@@ -136,6 +136,17 @@ int main(void) {
     // Cleanup happens automatically -> no warning.
   }
 
+  /// Function pointers
+  {
+    int __attribute__((requires_capability(&mu1))) (*function_ptr)(int) = Foo_fun1;
----------------
AaronBallman wrote:

Er, not certain I agree that should be a separate change -- I don't see *anything* hooking this up as a type attribute beyond the change to `DeclOrTypeAttr` in `Attr.td`. Declaration attributes have a ton of tablegenerated code that hooks things up for them, but type attributes are special and require more involved manual work.

I would have expected to see changes [in here](https://github.com/llvm/llvm-project/blob/28b7e281d4eaea0d5d56b1a4cf7a550be746a007/clang/lib/Sema/SemaType.cpp#L8615) to hook this up with the type system. Once the type is wrapped in an attribute, the diagnostic behavior you're looking for should come along "for free".

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


More information about the cfe-commits mailing list