aboutsummaryrefslogtreecommitdiff
path: root/libc/src/stdlib
diff options
context:
space:
mode:
authorLeonard Chan <leonardchan@google.com>2023-06-07 18:44:52 +0000
committerLeonard Chan <leonardchan@google.com>2023-06-07 18:46:15 +0000
commit8f360c3560d4d9f093482368475ded761a8cb9ab (patch)
treedd5b7cf3e8b32e3e83039cc836c86780f9f281ee /libc/src/stdlib
parent467688527017efb611b09c0cbf92f2d3ecdd1724 (diff)
downloadllvm-8f360c3560d4d9f093482368475ded761a8cb9ab.zip
llvm-8f360c3560d4d9f093482368475ded761a8cb9ab.tar.gz
llvm-8f360c3560d4d9f093482368475ded761a8cb9ab.tar.bz2
[libc] Temporarily suppress -fsanitize=function for qsort comparator
Recent upstream changes to -fsanitize=function find more instances of function type mismatches. One case is with the comparator passed to this class. Libraries like boringssl will tend to pass comparators that take pointers to varying types while this comparator expects to accept const void pointers. Ideally those tools would pass a function that strictly accepts const void*s to avoid UB, or we'd have something like qsort_r/s. Differential Revision: https://reviews.llvm.org/D152322
Diffstat (limited to 'libc/src/stdlib')
-rw-r--r--libc/src/stdlib/qsort.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/libc/src/stdlib/qsort.cpp b/libc/src/stdlib/qsort.cpp
index f6e2fc1..0efeea9 100644
--- a/libc/src/stdlib/qsort.cpp
+++ b/libc/src/stdlib/qsort.cpp
@@ -41,6 +41,15 @@ public:
}
}
+#if defined(__clang__)
+ // Recent upstream changes to -fsanitize=function find more instances of
+ // function type mismatches. One case is with the comparator passed to this
+ // class. Libraries like boringssl will tend to pass comparators that take
+ // pointers to varying types while this comparator expects to accept const
+ // void pointers. Ideally those tools would pass a function that strictly
+ // accepts const void*s to avoid UB, or we'd have something like qsort_r/s.
+ [[clang::no_sanitize("function")]]
+#endif
int elem_compare(size_t i, const uint8_t *other) const {
// An element must compare equal to itself so we don't need to consult the
// user provided comparator.