[clang] Support `guarded_by` attribute and related attributes inside C structs and support late parsing them (PR #95455)

Aaron Puchert via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 30 17:54:40 PDT 2024


================
@@ -29,6 +30,22 @@ struct LOCKABLE Mutex {};
 
 struct Foo {
   struct Mutex *mu_;
+  int  a_value GUARDED_BY(mu_);
+
+  struct Bar {
+    struct Mutex *other_mu ACQUIRED_AFTER(mu_);
----------------
aaronpuchert wrote:

I'm not entirely sure how nested `struct`s work in C, but should we be able to reference the parent from the child? At least in C++, you can declare objects of the child independent of the parent, so this wouldn't be meaningful.

This is an existing issue with with the `ACQUIRED_{AFTER,BEFORE}` implementation, but if you add a test for this (which is Ok to make sure it doesn't crash), you should probably also add a comment that this should perhaps be disallowed because it's not meaningful (as I understand).

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


More information about the cfe-commits mailing list