[cfe-users] thread safety annotations false negative

RJ Ryan via cfe-users cfe-users at lists.llvm.org
Wed Apr 27 17:36:03 PDT 2016


+cfe-dev -- in case anyone knows why this happens.

Thanks!

On Sat, Apr 23, 2016 at 1:41 PM, RJ Ryan <rryan at alum.mit.edu> wrote:

> Hi there,
>
> The following code only produces thread safety warnings for me in
> get_foo_copy, not get_foo_reference. Is this expected? Sorry if this is a
> FAQ / known issue.
>
> $ clang --version
> Apple LLVM version 7.0.2 (clang-700.1.81)
> Target: x86_64-apple-darwin15.3.0
> Thread model: posix
>
> The problem also seems present on clang 3.8.0:
> https://godbolt.org/g/37DqNy
>
> Best,
> RJ
>
> (with the usual thread annotation definitions)
>
> class CAPABILITY("mutex") Mutex {
>   public:
>     Mutex() {}
>     inline void lock() ACQUIRE() {}
>     inline void unlock() RELEASE() {}
> };
>
> class Foo {
>   public:
>     int& get_foo_reference() {
>         return foo_;
>     }
>
>     int get_foo_copy() {
>         return foo_;
>     }
>
>   private:
>     Mutex foo_lock_;
>     int foo_ GUARDED_BY(foo_lock_);
> };
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20160427/d745d3e1/attachment.html>


More information about the cfe-users mailing list