[PATCH] D55483: Introduce the callback attribute and emit !callback metadata
Johannes Doerfert via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 13 07:06:29 PST 2018
jdoerfert marked 2 inline comments as done.
jdoerfert added inline comments.
================
Comment at: include/clang/Basic/Builtins.def:942
LIBBUILTIN(alloca, "v*z", "f", "stdlib.h", ALL_GNU_LANGUAGES)
+LIBBUILTIN(qsort_r, "", "fC<3,-1,-1,4>", "stdlib.h", ALL_GNU_LANGUAGES)
// POSIX string.h
----------------
arichardson wrote:
> qsort_r callback argument order is different on Linux, macOS and FreeBSD so those constants can't be hardcoded:
> Linux:
> `void qsort_r(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *arg);`
> FreeBSD:
> `void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, int (*compar)(void *, const void *, const void*));`
> macos:
> `void qsort_r(void *base, size_t nel, size_t width, void *thunk, int (*compar)(void *, const void *, const void *));`
Really good point. I'll remove qsort_r in the next version I guess. If we find another similar function we can extend the encoding to sth like: `C:(<3,-1,-1,4>|<5,4,-1,-1>)` which represents both possibilities. The `Builtin::Context::performsCallback(...)` will then need to check which is appropriate based on the type of the actual declaration.
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