[all-commits] [llvm/llvm-project] b12ea0: [libc++] Include C++ headers, not C headers, in <c...

Quuxplusone via All-commits all-commits at lists.llvm.org
Thu Dec 10 19:08:12 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: b12ea0652129da3b42642a0b76adbfab8833db53
      https://github.com/llvm/llvm-project/commit/b12ea0652129da3b42642a0b76adbfab8833db53
  Author: Arthur O'Dwyer <arthur.j.odwyer at gmail.com>
  Date:   2020-12-10 (Thu, 10 Dec 2020)

  Changed paths:
    M libcxx/include/charconv

  Log Message:
  -----------
  [libc++] Include C++ headers, not C headers, in <charconv>.

This matches how libc++ does it in all other C++ headers
(that is, headers not ending in ".h").
We need to include <cstring> if we want to use `_VSTD::memmove`
instead of unqualified ADL `memmove`. Even though ADL doesn't
physically matter in <charconv>'s specific case, I'm trying
to migrate libc++ to using `_VSTD::memmove` for all cases
(because some of them do matter, and this way it's easier to
grep for outliers).

Differential Revision: https://reviews.llvm.org/D92875


  Commit: 3696227c10f5e5841223c2a2fb63fdd1d50a7930
      https://github.com/llvm/llvm-project/commit/3696227c10f5e5841223c2a2fb63fdd1d50a7930
  Author: Arthur O'Dwyer <arthur.j.odwyer at gmail.com>
  Date:   2020-12-10 (Thu, 10 Dec 2020)

  Changed paths:
    M libcxx/include/__hash_table
    M libcxx/include/__locale
    M libcxx/include/__string
    M libcxx/include/atomic
    M libcxx/include/fstream
    M libcxx/include/list
    M libcxx/include/locale
    M libcxx/include/string
    M libcxx/include/strstream
    M libcxx/include/vector

  Log Message:
  -----------
  [libc++] ADL-proof by adding _VSTD:: qualifications to memmove etc.

Generally these calls aren't vulnerable to ADL because they involve only
primitive types. The ones in <list> and <vector> drag in namespace std
but that's OK; the ones in <fstream> and <strstream> are vulnerable
iff `CharT` is an enum type, which seems far-fetched.
But 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.

Also: Include <cstring> and <cwchar> in <__string>.
We seemed to be getting lucky that <memory> included <iterator>
included <iosfwd> included <wchar.h>. That gave us the
global-namespace `wmemmove`, but not `_VSTD::wmemmove`.
This is now fixed.

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

Differential Revision: https://reviews.llvm.org/D93061


Compare: https://github.com/llvm/llvm-project/compare/0f1f13fcb17f...3696227c10f5


More information about the All-commits mailing list