Thread safety analysis: Mock getter for private mutexes can be undefined
authorAaron Puchert <aaron.puchert@sap.com>
Fri, 23 Jul 2021 12:45:56 +0000 (14:45 +0200)
committerAaron Puchert <aaron.puchert@sap.com>
Fri, 23 Jul 2021 12:46:02 +0000 (14:46 +0200)
Usage in an annotation is no odr-use, so I think there needs to be no
definition. Upside is that in practice one will get linker errors if it
is actually odr-used instead of calling a function that returns 0.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D106375

clang/docs/ThreadSafetyAnalysis.rst

index 651229f..69046ba 100644 (file)
@@ -640,8 +640,8 @@ mutex.  For example:
     Mutex mu;
 
   public:
-    // For thread safety analysis only.  Does not actually return mu.
-    Mutex* getMu() RETURN_CAPABILITY(mu) { return 0; }
+    // For thread safety analysis only.  Does not need to be defined.
+    Mutex* getMu() RETURN_CAPABILITY(mu);
 
     void doSomething() REQUIRES(mu);
   };