================
@@ -533,14 +534,33 @@ void test(Ops *ops) {
 }
 ```
 
-Note that the attributes are on the *variable* (or field), not on the function
-pointer type. Assigning a function with different (or no) attributes to an
-annotated function pointer variable is not diagnosed. The analysis trusts the
-annotations on the variable at the call site.
+On a parameter, the attributes describe the function reached through the
+parameter, not a capability that the argument stands for: they are checked
+where the parameter is called, and are neither requirements on nor effects for
+callers of the enclosing function. (Contrast this with a parameter of
+`scoped_lockable` reference type, where the attributes describe the locks that
+the passed scope object holds; see {ref}`scoped_capability`.)
 
-This support is limited to plain function pointers. Pointers-to-member
-functions, blocks, and wrapper types such as `std::function` are not
-supported yet.
+```c++
+void visit_all(void (*visit)(int) REQUIRES(mu), int n) {
+  visit(n); // warning: calling function 'visit' requires holding mutex 'mu'
----------------
melver wrote:

I would fold this example into the FP example block above.

Maybe make it a positive example where 'mu' is held around the vall to visit().

https://github.com/llvm/llvm-project/pull/211885
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to