Hello,
We are interested in applying ThreadSafetyAnalysis to C code
(specifically the Linux kernel).
However, the very common usecase of declaring a struct member to be
protected by another lockable struct member inside the same struct does
not work (see addition to test below). This results in an error:
clang/test/Sema/warn-thread-safety-analysis.c:36:24: error: use of undeclared identifier 'mu'
int data1 GUARDED_BY(mu);
^
clang/test/Sema/warn-thread-safety-analysis.c:38:24: error: use of undeclared identifier 'mu'
int data2 GUARDED_BY(mu);
AFAIK, this is the main limitation preventing us to use it on the Linux
kernel.
Does anyone know what's going on here?
Thanks,
-- Marco
------ >8 ------
diff --git a/clang/test/Sema/warn-thread-safety-analysis.c b/clang/test/Sema/warn-thread-safety-analysis.c
index a45fb8e0f382..6b75db4c246e 100644
--- a/clang/test/Sema/warn-thread-safety-analysis.c
+++ b/clang/test/Sema/warn-thread-safety-analysis.c
@@ -31,6 +31,13 @@ struct Foo {
struct Mutex *mu_;
};
+// Struct with mutex protecting data within.
+struct Bar {
+ int data1 GUARDED_BY(mu);
+ struct Mutex mu;
+ int data2 GUARDED_BY(mu);
+};