[libcxx-commits] [PATCH] D92776: [libc++] ADL-proof <algorithm> by adding _VSTD:: qualification on calls.
Arthur O'Dwyer via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Dec 7 10:30:44 PST 2020
Quuxplusone created this revision.
Quuxplusone added a reviewer: ldionne.
Quuxplusone added a project: libc++.
Quuxplusone requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: libcxx-commits, sstefan1.
Herald added a reviewer: libc++.
I intend to land this PR as two separate commits:
(1) [libc++] ADL-proof by adding _VSTD:: qualifications to memmove etc.
Many of these calls aren't vulnerable to ADL because they involve only
primitive types; but some (such as the ones in <list>) *are* vulnerable,
and absolutely zero of them *need* ADL to happen; so in my opinion
they should all be consistently qualified, just like calls to any
other (non-user-customizable) functions in namespace std.
The following names are covered by this patch:
memmove, wmemmove, memcpy, wmemcpy, memcmp, wmemcmp, memchr, wmemchr, strcmp, strlen, wcslen
I checked the following names but these aren't actually called anywhere:
strcpy, strncpy, strncmp, wcscmp
I didn't touch these headers:
<ext/__hash> uses strlen, safely
<support/ibm/locale_mgmt_aix.h> uses memcpy, safely
<string.h> uses memchr and strchr, safely
<wchar.h> uses wcschr, safely
<__bsd_locale_fallbacks.h> uses wcsnrtombs, safely
(2) [libc++] Add _VSTD:: qualifications to ADL-proof <algorithm>.
Relevant blog post: https://quuxplusone.github.io/blog/2019/09/26/uglification-doesnt-stop-adl/
@ldionne: In the <algorithm> commit, I noticed that there are several places where otherwise-well-formed code has been commented out; e.g. look at the codepath in `__nth_element` following `not_sorted:`. The commented-out stuff dates back to @howard.hinnant's initial commit. Can I just remove the commented-out stuff, in a separate "NFC" commit?
rG LLVM Github Monorepo
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 56702 bytes
Desc: not available
More information about the libcxx-commits