[libcxx-commits] [PATCH] D103558: [libcxx] Remove VLA from libcxx locale header

Abhina Sree via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jun 8 10:59:56 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rGee2a92c29df6: [libcxx] Remove VLA from libcxx locale header (authored by DanielMcIntosh-IBM, committed by abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103558

Files:
  libcxx/include/locale


Index: libcxx/include/locale
===================================================================
--- libcxx/include/locale
+++ libcxx/include/locale
@@ -1460,10 +1460,10 @@
     this->__format_int(__fmt+1, __len, true, __iob.flags());
     // Worst case is octal, with showbase enabled. Note that octal is always
     // printed as an unsigned value.
-    const unsigned __nbuf = (numeric_limits<unsigned long>::digits / 3)          // 1 char per 3 bits
-                            + ((numeric_limits<unsigned long>::digits % 3) != 0) // round up
-                            + ((__iob.flags() & ios_base::showbase) != 0)        // base prefix
-                            + 1;                                                 // terminating null character
+    _LIBCPP_CONSTEXPR const unsigned __nbuf
+        = (numeric_limits<unsigned long>::digits / 3)        // 1 char per 3 bits
+        + ((numeric_limits<unsigned long>::digits % 3) != 0) // round up
+        + 2; // base prefix + terminating null character
     char __nar[__nbuf];
     int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
     char* __ne = __nar + __nc;
@@ -1489,10 +1489,10 @@
     this->__format_int(__fmt+1, __len, true, __iob.flags());
     // Worst case is octal, with showbase enabled. Note that octal is always
     // printed as an unsigned value.
-    const unsigned __nbuf = (numeric_limits<unsigned long long>::digits / 3)          // 1 char per 3 bits
-                            + ((numeric_limits<unsigned long long>::digits % 3) != 0) // round up
-                            + ((__iob.flags() & ios_base::showbase) != 0)             // base prefix
-                            + 1;                                                      // terminating null character
+    _LIBCPP_CONSTEXPR const unsigned __nbuf
+        = (numeric_limits<unsigned long long>::digits / 3)        // 1 char per 3 bits
+        + ((numeric_limits<unsigned long long>::digits % 3) != 0) // round up
+        + 2; // base prefix + terminating null character
     char __nar[__nbuf];
     int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
     char* __ne = __nar + __nc;
@@ -1517,10 +1517,10 @@
     const char* __len = "l";
     this->__format_int(__fmt+1, __len, false, __iob.flags());
     // Worst case is octal, with showbase enabled.
-    const unsigned __nbuf = (numeric_limits<unsigned long>::digits / 3)          // 1 char per 3 bits
-                            + ((numeric_limits<unsigned long>::digits % 3) != 0) // round up
-                            + ((__iob.flags() & ios_base::showbase) != 0)        // base prefix
-                            + 1;                                                 // terminating null character
+    _LIBCPP_CONSTEXPR const unsigned __nbuf
+        = (numeric_limits<unsigned long>::digits / 3)        // 1 char per 3 bits
+        + ((numeric_limits<unsigned long>::digits % 3) != 0) // round up
+        + 2; // base prefix + terminating null character
     char __nar[__nbuf];
     int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
     char* __ne = __nar + __nc;
@@ -1545,10 +1545,10 @@
     const char* __len = "ll";
     this->__format_int(__fmt+1, __len, false, __iob.flags());
     // Worst case is octal, with showbase enabled.
-    const unsigned __nbuf = (numeric_limits<unsigned long long>::digits / 3)          // 1 char per 3 bits
-                            + ((numeric_limits<unsigned long long>::digits % 3) != 0) // round up
-                            + ((__iob.flags() & ios_base::showbase) != 0)             // base prefix
-                            + 1;                                                      // terminating null character
+    _LIBCPP_CONSTEXPR const unsigned __nbuf
+        = (numeric_limits<unsigned long long>::digits / 3)        // 1 char per 3 bits
+        + ((numeric_limits<unsigned long long>::digits % 3) != 0) // round up
+        + 2; // base prefix + terminating null character
     char __nar[__nbuf];
     int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
     char* __ne = __nar + __nc;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103558.350664.patch
Type: text/x-patch
Size: 4216 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210608/5cdc1152/attachment.bin>


More information about the libcxx-commits mailing list