[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_);
+    struct Mutex *third_mu ACQUIRED_BEFORE(other_mu);
+  } bar;
+
+  int* a_ptr PT_GUARDED_BY(bar.other_mu);
+};
+
+struct LOCKABLE Lock {};
+struct A {
+        struct Lock lock;
+        union {
+                int b __attribute__((guarded_by(lock)));
----------------
aaronpuchert wrote:

Tricky, see #78131.

But as above, testing that it doesn't crash is fine.

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


More information about the cfe-commits mailing list