[cfe-users] thread safety annotations false negative

RJ Ryan via cfe-users cfe-users at lists.llvm.org
Sat Apr 23 13:41:25 PDT 2016


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/20160423/8a164348/attachment.html>


More information about the cfe-users mailing list