[libcxx-commits] [PATCH] D92875: [libc++] Include C++ headers, not C headers, in <charconv>

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Dec 8 11:48:58 PST 2020

Quuxplusone created this revision.
Quuxplusone added reviewers: ldionne, lichray.
Quuxplusone added a project: libc++.
Quuxplusone requested review of this revision.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

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).

  rG LLVM Github Monorepo



Index: libcxx/include/charconv
--- libcxx/include/charconv
+++ libcxx/include/charconv
@@ -76,11 +76,11 @@
 #include <__config>
 #include <__availability>
 #include <__errc>
-#include <type_traits>
+#include <cmath> // for log2f
+#include <cstdint>
+#include <cstring>
 #include <limits>
-#include <stdint.h>
-#include <string.h>
-#include <math.h>
+#include <type_traits>
 #include <__debug>
@@ -333,7 +333,7 @@
         auto __len = __p - __buf;
         if (__len <= __diff)
-            memcpy(__first, __buf, __len);
+            _VSTD::memcpy(__first, __buf, __len);
             return {__first + __len, {}};
@@ -382,7 +382,7 @@
         return {__last, errc::value_too_large};
-        memmove(__first, __p, __len);
+        _VSTD::memmove(__first, __p, __len);
         return {__first + __len, {}};
@@ -429,7 +429,7 @@
         if (__x <= __complement(__to_unsigned(__tl::min())))
             __x = __complement(__x);
-            memcpy(&__value, &__x, sizeof(__x));
+            _VSTD::memcpy(&__value, &__x, sizeof(__x));
             return __r;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92875.310304.patch
Type: text/x-patch
Size: 1225 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20201208/161aa503/attachment.bin>

More information about the libcxx-commits mailing list