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

Pierre d'Herbemont via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 1 07:04:07 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_);
----------------
pdherbemont wrote:

> I'm not entirely sure how nested structs work in C, but should we be able to reference the parent from the child?

I think so, it does read nicely it feels – I see why this could cause a problem though: if the child structure is used outside of the parent, there is an ambiguity. Maybe this should be restricted to anonymous struct? Or maybe we need to taint the child struct so that it's not reused outside of the parent?

Anyhow, I'll add a comment as suggested!

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


More information about the cfe-commits mailing list