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

Alexander Richardson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 13 01:35:06 PST 2018


arichardson 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
----------------
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 *));`


================
Comment at: test/CodeGen/callback_qsort_r.c:1
+// RUN: %clang %s -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -D_GNU_SOURCE %s -S -c -emit-llvm -o - -O1 | FileCheck %s --check-prefix=IR
----------------
This should use a linux triple otherwise the qsort_r declaration is wrong. Ideally it should also handle macos+FreeBSD with the inverted argument order.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55483





More information about the llvm-commits mailing list