[PATCH] D106375: Thread safety analysis: Mock getter for private mutexes can be undefined

Aaron Puchert via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 20 09:11:12 PDT 2021


aaronpuchert created this revision.
aaronpuchert added a reviewer: aaron.ballman.
aaronpuchert requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106375

Files:
  clang/docs/ThreadSafetyAnalysis.rst


Index: clang/docs/ThreadSafetyAnalysis.rst
===================================================================
--- clang/docs/ThreadSafetyAnalysis.rst
+++ clang/docs/ThreadSafetyAnalysis.rst
@@ -640,8 +640,8 @@
     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);
   };


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106375.360167.patch
Type: text/x-patch
Size: 526 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210720/1dcafe05/attachment.bin>


More information about the cfe-commits mailing list