[PATCH] D14731: [libcxx] Add clang thread safety annotations to mutex and lock_guard
James Robinson via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 11 10:33:58 PST 2016
jamesr added a comment.
Thank you for posting the LIT changes - that's the part I was unable to figure out. I have a number of additional failure test cases that I will add.
I don't know what sort of code this could break, although I certainly don't claim to know more about these annotations than the author. Do you have a link to that discussion handy? The most obvious way this could break existing code would be if existing code was compiling with -Wthread-safety and had its own annotations that were inconsistent with these, but as it's a compile error to declare thread-safety relationships with types that aren't already annotated I can't see how any code that would be broken could compile today. Concretely, if some code is written like this today:
struct Foo {
int a __attribute__((guarded_by(m)));
std::mutex m;
};
void Bad(Foo* f) { f->a++; }
will fail to compile without this patch in libc++ with the error:
/tmp/test.cc:4:26: error: 'guarded_by' attribute requires arguments whose type is annotated with 'capability' attribute; type here is 'std::mutex'
[-Werror,-Wthread-safety-attributes]
int a __attribute__((guarded_by(m))
http://reviews.llvm.org/D14731
More information about the cfe-commits
mailing list