[PATCH] D55483: Introduce the callback attribute and emit !callback metadata

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 10 12:18:54 PST 2018


aaron.ballman requested changes to this revision.
aaron.ballman added a comment.
This revision now requires changes to proceed.

This is missing all of the Sema and SemaCXX tests. Should have tests for member functions, variadic functions, incorrect arguments, incorrect subjects, etc.



================
Comment at: include/clang/Basic/Attr.td:1204
+              VariadicUnsignedArgument<"PayloadIndices">];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [Undocumented];
----------------
Should this also apply to Objective-C methods?

Why should the user specify this attribute on the function as opposed to on the parameter? e.g.,
```
// Why this:
__attribute__((callback (1, 2, 3)))
void* broker0(void* (*callee)(void *), void *payload, int otherPayload) {
  return callee(payload);
}

// Instead of this:
void* broker0(void* (*callee)(void *) __attribute__((callback (2, 3))), void *payload, int otherPayload) {
  return callee(payload);
}

// Or this:
void* broker0(void* (*callee)(void *) __attribute__((callback (payload, otherPayload))), void *payload, int otherPayload) {
  return callee(payload);
}
```
I ask because these "use an index" attributes are really hard for users to use in practice. They have to account for 0-vs-1 based indexing, implicit this parameters, etc and if we can avoid that, it may be worth the effort.


================
Comment at: include/clang/Basic/Attr.td:1205
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [Undocumented];
+}
----------------
No new undocumented attributes, please.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55483/new/

https://reviews.llvm.org/D55483





More information about the cfe-commits mailing list