[libc++] Make the naming of private member variables consistent and enforce it through readability-identifier-naming

Reviewed By: ldionne, #libc

Spies: aheejin, sstefan1, libcxx-commits

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

NOKEYCHECK=True
GitOrigin-RevId: 84fc2c3cd62ab5be51d65f818854bb031b74c0f2
diff --git a/src/locale.cpp b/src/locale.cpp
index 02da95c..e5035bd 100644
--- a/src/locale.cpp
+++ b/src/locale.cpp
@@ -739,25 +739,25 @@
 
 collate_byname<char>::collate_byname(const char* n, size_t refs)
     : collate<char>(refs),
-      __l(newlocale(LC_ALL_MASK, n, 0))
+      __l_(newlocale(LC_ALL_MASK, n, 0))
 {
-    if (__l == 0)
+    if (__l_ == 0)
         __throw_runtime_error("collate_byname<char>::collate_byname"
                             " failed to construct for " + string(n));
 }
 
 collate_byname<char>::collate_byname(const string& name, size_t refs)
     : collate<char>(refs),
-      __l(newlocale(LC_ALL_MASK, name.c_str(), 0))
+      __l_(newlocale(LC_ALL_MASK, name.c_str(), 0))
 {
-    if (__l == 0)
+    if (__l_ == 0)
         __throw_runtime_error("collate_byname<char>::collate_byname"
                             " failed to construct for " + name);
 }
 
 collate_byname<char>::~collate_byname()
 {
-    freelocale(__l);
+    freelocale(__l_);
 }
 
 int
@@ -766,7 +766,7 @@
 {
     string_type lhs(__lo1, __hi1);
     string_type rhs(__lo2, __hi2);
-    int r = strcoll_l(lhs.c_str(), rhs.c_str(), __l);
+    int r = strcoll_l(lhs.c_str(), rhs.c_str(), __l_);
     if (r < 0)
         return -1;
     if (r > 0)
@@ -778,8 +778,8 @@
 collate_byname<char>::do_transform(const char_type* lo, const char_type* hi) const
 {
     const string_type in(lo, hi);
-    string_type out(strxfrm_l(0, in.c_str(), 0, __l), char());
-    strxfrm_l(const_cast<char*>(out.c_str()), in.c_str(), out.size()+1, __l);
+    string_type out(strxfrm_l(0, in.c_str(), 0, __l_), char());
+    strxfrm_l(const_cast<char*>(out.c_str()), in.c_str(), out.size()+1, __l_);
     return out;
 }
 
@@ -788,25 +788,25 @@
 #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
 collate_byname<wchar_t>::collate_byname(const char* n, size_t refs)
     : collate<wchar_t>(refs),
-      __l(newlocale(LC_ALL_MASK, n, 0))
+      __l_(newlocale(LC_ALL_MASK, n, 0))
 {
-    if (__l == 0)
+    if (__l_ == 0)
         __throw_runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)"
                             " failed to construct for " + string(n));
 }
 
 collate_byname<wchar_t>::collate_byname(const string& name, size_t refs)
     : collate<wchar_t>(refs),
-      __l(newlocale(LC_ALL_MASK, name.c_str(), 0))
+      __l_(newlocale(LC_ALL_MASK, name.c_str(), 0))
 {
-    if (__l == 0)
+    if (__l_ == 0)
         __throw_runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)"
                             " failed to construct for " + name);
 }
 
 collate_byname<wchar_t>::~collate_byname()
 {
-    freelocale(__l);
+    freelocale(__l_);
 }
 
 int
@@ -815,7 +815,7 @@
 {
     string_type lhs(__lo1, __hi1);
     string_type rhs(__lo2, __hi2);
-    int r = wcscoll_l(lhs.c_str(), rhs.c_str(), __l);
+    int r = wcscoll_l(lhs.c_str(), rhs.c_str(), __l_);
     if (r < 0)
         return -1;
     if (r > 0)
@@ -827,8 +827,8 @@
 collate_byname<wchar_t>::do_transform(const char_type* lo, const char_type* hi) const
 {
     const string_type in(lo, hi);
-    string_type out(wcsxfrm_l(0, in.c_str(), 0, __l), wchar_t());
-    wcsxfrm_l(const_cast<wchar_t*>(out.c_str()), in.c_str(), out.size()+1, __l);
+    string_type out(wcsxfrm_l(0, in.c_str(), 0, __l_), wchar_t());
+    wcsxfrm_l(const_cast<wchar_t*>(out.c_str()), in.c_str(), out.size()+1, __l_);
     return out;
 }
 #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
@@ -1286,52 +1286,52 @@
 
 ctype_byname<char>::ctype_byname(const char* name, size_t refs)
     : ctype<char>(0, false, refs),
-      __l(newlocale(LC_ALL_MASK, name, 0))
+      __l_(newlocale(LC_ALL_MASK, name, 0))
 {
-    if (__l == 0)
+    if (__l_ == 0)
         __throw_runtime_error("ctype_byname<char>::ctype_byname"
                             " failed to construct for " + string(name));
 }
 
 ctype_byname<char>::ctype_byname(const string& name, size_t refs)
     : ctype<char>(0, false, refs),
-      __l(newlocale(LC_ALL_MASK, name.c_str(), 0))
+      __l_(newlocale(LC_ALL_MASK, name.c_str(), 0))
 {
-    if (__l == 0)
+    if (__l_ == 0)
         __throw_runtime_error("ctype_byname<char>::ctype_byname"
                             " failed to construct for " + name);
 }
 
 ctype_byname<char>::~ctype_byname()
 {
-    freelocale(__l);
+    freelocale(__l_);
 }
 
 char
 ctype_byname<char>::do_toupper(char_type c) const
 {
-    return static_cast<char>(toupper_l(static_cast<unsigned char>(c), __l));
+    return static_cast<char>(toupper_l(static_cast<unsigned char>(c), __l_));
 }
 
 const char*
 ctype_byname<char>::do_toupper(char_type* low, const char_type* high) const
 {
     for (; low != high; ++low)
-        *low = static_cast<char>(toupper_l(static_cast<unsigned char>(*low), __l));
+        *low = static_cast<char>(toupper_l(static_cast<unsigned char>(*low), __l_));
     return low;
 }
 
 char
 ctype_byname<char>::do_tolower(char_type c) const
 {
-    return static_cast<char>(tolower_l(static_cast<unsigned char>(c), __l));
+    return static_cast<char>(tolower_l(static_cast<unsigned char>(c), __l_));
 }
 
 const char*
 ctype_byname<char>::do_tolower(char_type* low, const char_type* high) const
 {
     for (; low != high; ++low)
-        *low = static_cast<char>(tolower_l(static_cast<unsigned char>(*low), __l));
+        *low = static_cast<char>(tolower_l(static_cast<unsigned char>(*low), __l_));
     return low;
 }
 
@@ -1340,45 +1340,45 @@
 #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
 ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs)
     : ctype<wchar_t>(refs),
-      __l(newlocale(LC_ALL_MASK, name, 0))
+      __l_(newlocale(LC_ALL_MASK, name, 0))
 {
-    if (__l == 0)
+    if (__l_ == 0)
         __throw_runtime_error("ctype_byname<wchar_t>::ctype_byname"
                             " failed to construct for " + string(name));
 }
 
 ctype_byname<wchar_t>::ctype_byname(const string& name, size_t refs)
     : ctype<wchar_t>(refs),
-      __l(newlocale(LC_ALL_MASK, name.c_str(), 0))
+      __l_(newlocale(LC_ALL_MASK, name.c_str(), 0))
 {
-    if (__l == 0)
+    if (__l_ == 0)
         __throw_runtime_error("ctype_byname<wchar_t>::ctype_byname"
                             " failed to construct for " + name);
 }
 
 ctype_byname<wchar_t>::~ctype_byname()
 {
-    freelocale(__l);
+    freelocale(__l_);
 }
 
 bool
 ctype_byname<wchar_t>::do_is(mask m, char_type c) const
 {
 #ifdef _LIBCPP_WCTYPE_IS_MASK
-    return static_cast<bool>(iswctype_l(c, m, __l));
+    return static_cast<bool>(iswctype_l(c, m, __l_));
 #else
     bool result = false;
     wint_t ch = static_cast<wint_t>(c);
-    if ((m & space) == space) result |= (iswspace_l(ch, __l) != 0);
-    if ((m & print) == print) result |= (iswprint_l(ch, __l) != 0);
-    if ((m & cntrl) == cntrl) result |= (iswcntrl_l(ch, __l) != 0);
-    if ((m & upper) == upper) result |= (iswupper_l(ch, __l) != 0);
-    if ((m & lower) == lower) result |= (iswlower_l(ch, __l) != 0);
-    if ((m & alpha) == alpha) result |= (iswalpha_l(ch, __l) != 0);
-    if ((m & digit) == digit) result |= (iswdigit_l(ch, __l) != 0);
-    if ((m & punct) == punct) result |= (iswpunct_l(ch, __l) != 0);
-    if ((m & xdigit) == xdigit) result |= (iswxdigit_l(ch, __l) != 0);
-    if ((m & blank) == blank) result |= (iswblank_l(ch, __l) != 0);
+    if ((m & space) == space) result |= (iswspace_l(ch, __l_) != 0);
+    if ((m & print) == print) result |= (iswprint_l(ch, __l_) != 0);
+    if ((m & cntrl) == cntrl) result |= (iswcntrl_l(ch, __l_) != 0);
+    if ((m & upper) == upper) result |= (iswupper_l(ch, __l_) != 0);
+    if ((m & lower) == lower) result |= (iswlower_l(ch, __l_) != 0);
+    if ((m & alpha) == alpha) result |= (iswalpha_l(ch, __l_) != 0);
+    if ((m & digit) == digit) result |= (iswdigit_l(ch, __l_) != 0);
+    if ((m & punct) == punct) result |= (iswpunct_l(ch, __l_) != 0);
+    if ((m & xdigit) == xdigit) result |= (iswxdigit_l(ch, __l_) != 0);
+    if ((m & blank) == blank) result |= (iswblank_l(ch, __l_) != 0);
     return result;
 #endif
 }
@@ -1394,32 +1394,32 @@
         {
             *vec = 0;
             wint_t ch = static_cast<wint_t>(*low);
-            if (iswspace_l(ch, __l))
+            if (iswspace_l(ch, __l_))
                 *vec |= space;
 #ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
-            if (iswprint_l(ch, __l))
+            if (iswprint_l(ch, __l_))
                 *vec |= print;
 #endif
-            if (iswcntrl_l(ch, __l))
+            if (iswcntrl_l(ch, __l_))
                 *vec |= cntrl;
-            if (iswupper_l(ch, __l))
+            if (iswupper_l(ch, __l_))
                 *vec |= upper;
-            if (iswlower_l(ch, __l))
+            if (iswlower_l(ch, __l_))
                 *vec |= lower;
 #ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
-            if (iswalpha_l(ch, __l))
+            if (iswalpha_l(ch, __l_))
                 *vec |= alpha;
 #endif
-            if (iswdigit_l(ch, __l))
+            if (iswdigit_l(ch, __l_))
                 *vec |= digit;
-            if (iswpunct_l(ch, __l))
+            if (iswpunct_l(ch, __l_))
                 *vec |= punct;
 #ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT
-            if (iswxdigit_l(ch, __l))
+            if (iswxdigit_l(ch, __l_))
                 *vec |= xdigit;
 #endif
 #if !defined(__sun__)
-            if (iswblank_l(ch, __l))
+            if (iswblank_l(ch, __l_))
                 *vec |= blank;
 #endif
         }
@@ -1433,20 +1433,20 @@
     for (; low != high; ++low)
     {
 #ifdef _LIBCPP_WCTYPE_IS_MASK
-        if (iswctype_l(*low, m, __l))
+        if (iswctype_l(*low, m, __l_))
             break;
 #else
         wint_t ch = static_cast<wint_t>(*low);
-        if ((m & space) == space && iswspace_l(ch, __l)) break;
-        if ((m & print) == print && iswprint_l(ch, __l)) break;
-        if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l)) break;
-        if ((m & upper) == upper && iswupper_l(ch, __l)) break;
-        if ((m & lower) == lower && iswlower_l(ch, __l)) break;
-        if ((m & alpha) == alpha && iswalpha_l(ch, __l)) break;
-        if ((m & digit) == digit && iswdigit_l(ch, __l)) break;
-        if ((m & punct) == punct && iswpunct_l(ch, __l)) break;
-        if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l)) break;
-        if ((m & blank) == blank && iswblank_l(ch, __l)) break;
+        if ((m & space) == space && iswspace_l(ch, __l_)) break;
+        if ((m & print) == print && iswprint_l(ch, __l_)) break;
+        if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l_)) break;
+        if ((m & upper) == upper && iswupper_l(ch, __l_)) break;
+        if ((m & lower) == lower && iswlower_l(ch, __l_)) break;
+        if ((m & alpha) == alpha && iswalpha_l(ch, __l_)) break;
+        if ((m & digit) == digit && iswdigit_l(ch, __l_)) break;
+        if ((m & punct) == punct && iswpunct_l(ch, __l_)) break;
+        if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l_)) break;
+        if ((m & blank) == blank && iswblank_l(ch, __l_)) break;
 #endif
     }
     return low;
@@ -1458,20 +1458,20 @@
     for (; low != high; ++low)
     {
 #ifdef _LIBCPP_WCTYPE_IS_MASK
-        if (!iswctype_l(*low, m, __l))
+        if (!iswctype_l(*low, m, __l_))
             break;
 #else
         wint_t ch = static_cast<wint_t>(*low);
-        if ((m & space) == space && iswspace_l(ch, __l)) continue;
-        if ((m & print) == print && iswprint_l(ch, __l)) continue;
-        if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l)) continue;
-        if ((m & upper) == upper && iswupper_l(ch, __l)) continue;
-        if ((m & lower) == lower && iswlower_l(ch, __l)) continue;
-        if ((m & alpha) == alpha && iswalpha_l(ch, __l)) continue;
-        if ((m & digit) == digit && iswdigit_l(ch, __l)) continue;
-        if ((m & punct) == punct && iswpunct_l(ch, __l)) continue;
-        if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l)) continue;
-        if ((m & blank) == blank && iswblank_l(ch, __l)) continue;
+        if ((m & space) == space && iswspace_l(ch, __l_)) continue;
+        if ((m & print) == print && iswprint_l(ch, __l_)) continue;
+        if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l_)) continue;
+        if ((m & upper) == upper && iswupper_l(ch, __l_)) continue;
+        if ((m & lower) == lower && iswlower_l(ch, __l_)) continue;
+        if ((m & alpha) == alpha && iswalpha_l(ch, __l_)) continue;
+        if ((m & digit) == digit && iswdigit_l(ch, __l_)) continue;
+        if ((m & punct) == punct && iswpunct_l(ch, __l_)) continue;
+        if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l_)) continue;
+        if ((m & blank) == blank && iswblank_l(ch, __l_)) continue;
         break;
 #endif
     }
@@ -1481,49 +1481,49 @@
 wchar_t
 ctype_byname<wchar_t>::do_toupper(char_type c) const
 {
-    return towupper_l(c, __l);
+    return towupper_l(c, __l_);
 }
 
 const wchar_t*
 ctype_byname<wchar_t>::do_toupper(char_type* low, const char_type* high) const
 {
     for (; low != high; ++low)
-        *low = towupper_l(*low, __l);
+        *low = towupper_l(*low, __l_);
     return low;
 }
 
 wchar_t
 ctype_byname<wchar_t>::do_tolower(char_type c) const
 {
-    return towlower_l(c, __l);
+    return towlower_l(c, __l_);
 }
 
 const wchar_t*
 ctype_byname<wchar_t>::do_tolower(char_type* low, const char_type* high) const
 {
     for (; low != high; ++low)
-        *low = towlower_l(*low, __l);
+        *low = towlower_l(*low, __l_);
     return low;
 }
 
 wchar_t
 ctype_byname<wchar_t>::do_widen(char c) const
 {
-    return __libcpp_btowc_l(c, __l);
+    return __libcpp_btowc_l(c, __l_);
 }
 
 const char*
 ctype_byname<wchar_t>::do_widen(const char* low, const char* high, char_type* dest) const
 {
     for (; low != high; ++low, ++dest)
-        *dest = __libcpp_btowc_l(*low, __l);
+        *dest = __libcpp_btowc_l(*low, __l_);
     return low;
 }
 
 char
 ctype_byname<wchar_t>::do_narrow(char_type c, char dfault) const
 {
-    int r = __libcpp_wctob_l(c, __l);
+    int r = __libcpp_wctob_l(c, __l_);
     return (r != EOF) ? static_cast<char>(r) : dfault;
 }
 
@@ -1532,7 +1532,7 @@
 {
     for (; low != high; ++low, ++dest)
     {
-        int r = __libcpp_wctob_l(*low, __l);
+        int r = __libcpp_wctob_l(*low, __l_);
         *dest = (r != EOF) ? static_cast<char>(r) : dfault;
     }
     return low;
@@ -1607,23 +1607,23 @@
 
 codecvt<wchar_t, char, mbstate_t>::codecvt(size_t refs)
     : locale::facet(refs),
-      __l(_LIBCPP_GET_C_LOCALE)
+      __l_(_LIBCPP_GET_C_LOCALE)
 {
 }
 
 codecvt<wchar_t, char, mbstate_t>::codecvt(const char* nm, size_t refs)
     : locale::facet(refs),
-      __l(newlocale(LC_ALL_MASK, nm, 0))
+      __l_(newlocale(LC_ALL_MASK, nm, 0))
 {
-    if (__l == 0)
+    if (__l_ == 0)
         __throw_runtime_error("codecvt_byname<wchar_t, char, mbstate_t>::codecvt_byname"
                             " failed to construct for " + string(nm));
 }
 
 codecvt<wchar_t, char, mbstate_t>::~codecvt()
 {
-    if (__l != _LIBCPP_GET_C_LOCALE)
-        freelocale(__l);
+    if (__l_ != _LIBCPP_GET_C_LOCALE)
+        freelocale(__l_);
 }
 
 codecvt<wchar_t, char, mbstate_t>::result
@@ -1643,13 +1643,13 @@
         // save state in case it is needed to recover to_nxt on error
         mbstate_t save_state = st;
         size_t n = __libcpp_wcsnrtombs_l(to, &frm_nxt, static_cast<size_t>(fend-frm),
-                                     static_cast<size_t>(to_end-to), &st, __l);
+                                     static_cast<size_t>(to_end-to), &st, __l_);
         if (n == size_t(-1))
         {
             // need to recover to_nxt
             for (to_nxt = to; frm != frm_nxt; ++frm)
             {
-                n = __libcpp_wcrtomb_l(to_nxt, *frm, &save_state, __l);
+                n = __libcpp_wcrtomb_l(to_nxt, *frm, &save_state, __l_);
                 if (n == size_t(-1))
                     break;
                 to_nxt += n;
@@ -1666,7 +1666,7 @@
         {
             // Try to write the terminating null
             extern_type tmp[MB_LEN_MAX];
-            n = __libcpp_wcrtomb_l(tmp, intern_type(), &st, __l);
+            n = __libcpp_wcrtomb_l(tmp, intern_type(), &st, __l_);
             if (n == size_t(-1))  // on error
                 return error;
             if (n > static_cast<size_t>(to_end-to_nxt))  // is there room?
@@ -1700,14 +1700,14 @@
         // save state in case it is needed to recover to_nxt on error
         mbstate_t save_state = st;
         size_t n = __libcpp_mbsnrtowcs_l(to, &frm_nxt, static_cast<size_t>(fend-frm),
-                                     static_cast<size_t>(to_end-to), &st, __l);
+                                     static_cast<size_t>(to_end-to), &st, __l_);
         if (n == size_t(-1))
         {
             // need to recover to_nxt
             for (to_nxt = to; frm != frm_nxt; ++to_nxt)
             {
                 n = __libcpp_mbrtowc_l(to_nxt, frm, static_cast<size_t>(fend-frm),
-                                   &save_state, __l);
+                                   &save_state, __l_);
                 switch (n)
                 {
                 case 0:
@@ -1735,7 +1735,7 @@
         if (fend != frm_end)  // set up next null terminated sequence
         {
             // Try to write the terminating null
-            n = __libcpp_mbrtowc_l(to_nxt, frm_nxt, 1, &st, __l);
+            n = __libcpp_mbrtowc_l(to_nxt, frm_nxt, 1, &st, __l_);
             if (n != 0)  // on error
                 return error;
             ++to_nxt;
@@ -1755,7 +1755,7 @@
 {
     to_nxt = to;
     extern_type tmp[MB_LEN_MAX];
-    size_t n = __libcpp_wcrtomb_l(tmp, intern_type(), &st, __l);
+    size_t n = __libcpp_wcrtomb_l(tmp, intern_type(), &st, __l_);
     if (n == size_t(-1) || n == 0)  // on error
         return error;
     --n;
@@ -1769,11 +1769,11 @@
 int
 codecvt<wchar_t, char, mbstate_t>::do_encoding() const noexcept
 {
-    if (__libcpp_mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l) != 0)
+    if (__libcpp_mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l_) != 0)
         return -1;
 
     // stateless encoding
-    if (__l == 0 || __libcpp_mb_cur_max_l(__l) == 1)  // there are no known constant length encodings
+    if (__l_ == 0 || __libcpp_mb_cur_max_l(__l_) == 1)  // there are no known constant length encodings
         return 1;                // which take more than 1 char to form a wchar_t
     return 0;
 }
@@ -1791,7 +1791,7 @@
     int nbytes = 0;
     for (size_t nwchar_t = 0; nwchar_t < mx && frm != frm_end; ++nwchar_t)
     {
-        size_t n = __libcpp_mbrlen_l(frm, static_cast<size_t>(frm_end-frm), &st, __l);
+        size_t n = __libcpp_mbrlen_l(frm, static_cast<size_t>(frm_end-frm), &st, __l_);
         switch (n)
         {
         case 0:
@@ -1813,7 +1813,7 @@
 int
 codecvt<wchar_t, char, mbstate_t>::do_max_length() const noexcept
 {
-    return __l == 0 ? 1 : static_cast<int>(__libcpp_mb_cur_max_l(__l));
+    return __l_ == 0 ? 1 : static_cast<int>(__libcpp_mb_cur_max_l(__l_));
 }
 #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
 
@@ -3545,10 +3545,10 @@
     uint8_t* _to_nxt = _to;
 #if defined(_LIBCPP_SHORT_WCHAR)
     result r = ucs2_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                            _Maxcode_, _Mode_);
+                            __maxcode_, __mode_);
 #else
     result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                            _Maxcode_, _Mode_);
+                            __maxcode_, __mode_);
 #endif
     frm_nxt = frm + (_frm_nxt - _frm);
     to_nxt = to + (_to_nxt - _to);
@@ -3568,13 +3568,13 @@
     uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
     uint16_t* _to_nxt = _to;
     result r = utf8_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                            _Maxcode_, _Mode_);
+                            __maxcode_, __mode_);
 #else
     uint32_t* _to = reinterpret_cast<uint32_t*>(to);
     uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
     uint32_t* _to_nxt = _to;
     result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                            _Maxcode_, _Mode_);
+                            __maxcode_, __mode_);
 #endif
     frm_nxt = frm + (_frm_nxt - _frm);
     to_nxt = to + (_to_nxt - _to);
@@ -3608,9 +3608,9 @@
     const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
     const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
 #if defined(_LIBCPP_SHORT_WCHAR)
-    return utf8_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+    return utf8_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_);
 #else
-    return utf8_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+    return utf8_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_);
 #endif
 }
 
@@ -3619,11 +3619,11 @@
 __codecvt_utf8<wchar_t>::do_max_length() const noexcept
 {
 #if defined(_LIBCPP_SHORT_WCHAR)
-    if (_Mode_ & consume_header)
+    if (__mode_ & consume_header)
         return 6;
     return 3;
 #else
-    if (_Mode_ & consume_header)
+    if (__mode_ & consume_header)
         return 7;
     return 4;
 #endif
@@ -3644,7 +3644,7 @@
     uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
     uint8_t* _to_nxt = _to;
     result r = ucs2_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                            _Maxcode_, _Mode_);
+                            __maxcode_, __mode_);
     frm_nxt = frm + (_frm_nxt - _frm);
     to_nxt = to + (_to_nxt - _to);
     return r;
@@ -3662,7 +3662,7 @@
     uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
     uint16_t* _to_nxt = _to;
     result r = utf8_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                            _Maxcode_, _Mode_);
+                            __maxcode_, __mode_);
     frm_nxt = frm + (_frm_nxt - _frm);
     to_nxt = to + (_to_nxt - _to);
     return r;
@@ -3694,14 +3694,14 @@
 {
     const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
     const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
-    return utf8_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+    return utf8_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_);
 }
 
 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
 int
 __codecvt_utf8<char16_t>::do_max_length() const noexcept
 {
-    if (_Mode_ & consume_header)
+    if (__mode_ & consume_header)
         return 6;
     return 3;
 }
@@ -3721,7 +3721,7 @@
     uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
     uint8_t* _to_nxt = _to;
     result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                            _Maxcode_, _Mode_);
+                            __maxcode_, __mode_);
     frm_nxt = frm + (_frm_nxt - _frm);
     to_nxt = to + (_to_nxt - _to);
     return r;
@@ -3739,7 +3739,7 @@
     uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
     uint32_t* _to_nxt = _to;
     result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                            _Maxcode_, _Mode_);
+                            __maxcode_, __mode_);
     frm_nxt = frm + (_frm_nxt - _frm);
     to_nxt = to + (_to_nxt - _to);
     return r;
@@ -3771,14 +3771,14 @@
 {
     const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
     const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
-    return utf8_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+    return utf8_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_);
 }
 
 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
 int
 __codecvt_utf8<char32_t>::do_max_length() const noexcept
 {
-    if (_Mode_ & consume_header)
+    if (__mode_ & consume_header)
         return 7;
     return 4;
 }
@@ -3806,10 +3806,10 @@
     uint8_t* _to_nxt = _to;
 #if defined(_LIBCPP_SHORT_WCHAR)
     result r = ucs2_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                               _Maxcode_, _Mode_);
+                               __maxcode_, __mode_);
 #else
     result r = ucs4_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                               _Maxcode_, _Mode_);
+                               __maxcode_, __mode_);
 #endif
     frm_nxt = frm + (_frm_nxt - _frm);
     to_nxt = to + (_to_nxt - _to);
@@ -3829,13 +3829,13 @@
     uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
     uint16_t* _to_nxt = _to;
     result r = utf16be_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                               _Maxcode_, _Mode_);
+                               __maxcode_, __mode_);
 #else
     uint32_t* _to = reinterpret_cast<uint32_t*>(to);
     uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
     uint32_t* _to_nxt = _to;
     result r = utf16be_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                               _Maxcode_, _Mode_);
+                               __maxcode_, __mode_);
 #endif
     frm_nxt = frm + (_frm_nxt - _frm);
     to_nxt = to + (_to_nxt - _to);
@@ -3869,9 +3869,9 @@
     const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
     const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
 #if defined(_LIBCPP_SHORT_WCHAR)
-    return utf16be_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+    return utf16be_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_);
 #else
-    return utf16be_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+    return utf16be_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_);
 #endif
 }
 
@@ -3879,11 +3879,11 @@
 __codecvt_utf16<wchar_t, false>::do_max_length() const noexcept
 {
 #if defined(_LIBCPP_SHORT_WCHAR)
-    if (_Mode_ & consume_header)
+    if (__mode_ & consume_header)
         return 4;
     return 2;
 #else
-    if (_Mode_ & consume_header)
+    if (__mode_ & consume_header)
         return 6;
     return 4;
 #endif
@@ -3910,10 +3910,10 @@
     uint8_t* _to_nxt = _to;
 #if defined(_LIBCPP_SHORT_WCHAR)
     result r = ucs2_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                               _Maxcode_, _Mode_);
+                               __maxcode_, __mode_);
 #else
     result r = ucs4_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                               _Maxcode_, _Mode_);
+                               __maxcode_, __mode_);
 #endif
     frm_nxt = frm + (_frm_nxt - _frm);
     to_nxt = to + (_to_nxt - _to);
@@ -3933,13 +3933,13 @@
     uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
     uint16_t* _to_nxt = _to;
     result r = utf16le_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                               _Maxcode_, _Mode_);
+                               __maxcode_, __mode_);
 #else
     uint32_t* _to = reinterpret_cast<uint32_t*>(to);
     uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
     uint32_t* _to_nxt = _to;
     result r = utf16le_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                               _Maxcode_, _Mode_);
+                               __maxcode_, __mode_);
 #endif
     frm_nxt = frm + (_frm_nxt - _frm);
     to_nxt = to + (_to_nxt - _to);
@@ -3973,9 +3973,9 @@
     const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
     const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
 #if defined(_LIBCPP_SHORT_WCHAR)
-    return utf16le_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+    return utf16le_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_);
 #else
-    return utf16le_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+    return utf16le_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_);
 #endif
 }
 
@@ -3983,11 +3983,11 @@
 __codecvt_utf16<wchar_t, true>::do_max_length() const noexcept
 {
 #if defined(_LIBCPP_SHORT_WCHAR)
-    if (_Mode_ & consume_header)
+    if (__mode_ & consume_header)
         return 4;
     return 2;
 #else
-    if (_Mode_ & consume_header)
+    if (__mode_ & consume_header)
         return 6;
     return 4;
 #endif
@@ -4008,7 +4008,7 @@
     uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
     uint8_t* _to_nxt = _to;
     result r = ucs2_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                               _Maxcode_, _Mode_);
+                               __maxcode_, __mode_);
     frm_nxt = frm + (_frm_nxt - _frm);
     to_nxt = to + (_to_nxt - _to);
     return r;
@@ -4026,7 +4026,7 @@
     uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
     uint16_t* _to_nxt = _to;
     result r = utf16be_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                               _Maxcode_, _Mode_);
+                               __maxcode_, __mode_);
     frm_nxt = frm + (_frm_nxt - _frm);
     to_nxt = to + (_to_nxt - _to);
     return r;
@@ -4058,14 +4058,14 @@
 {
     const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
     const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
-    return utf16be_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+    return utf16be_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_);
 }
 
 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
 int
 __codecvt_utf16<char16_t, false>::do_max_length() const noexcept
 {
-    if (_Mode_ & consume_header)
+    if (__mode_ & consume_header)
         return 4;
     return 2;
 }
@@ -4085,7 +4085,7 @@
     uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
     uint8_t* _to_nxt = _to;
     result r = ucs2_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                               _Maxcode_, _Mode_);
+                               __maxcode_, __mode_);
     frm_nxt = frm + (_frm_nxt - _frm);
     to_nxt = to + (_to_nxt - _to);
     return r;
@@ -4103,7 +4103,7 @@
     uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
     uint16_t* _to_nxt = _to;
     result r = utf16le_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                               _Maxcode_, _Mode_);
+                               __maxcode_, __mode_);
     frm_nxt = frm + (_frm_nxt - _frm);
     to_nxt = to + (_to_nxt - _to);
     return r;
@@ -4135,14 +4135,14 @@
 {
     const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
     const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
-    return utf16le_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+    return utf16le_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_);
 }
 
 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
 int
 __codecvt_utf16<char16_t, true>::do_max_length() const noexcept
 {
-    if (_Mode_ & consume_header)
+    if (__mode_ & consume_header)
         return 4;
     return 2;
 }
@@ -4162,7 +4162,7 @@
     uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
     uint8_t* _to_nxt = _to;
     result r = ucs4_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                               _Maxcode_, _Mode_);
+                               __maxcode_, __mode_);
     frm_nxt = frm + (_frm_nxt - _frm);
     to_nxt = to + (_to_nxt - _to);
     return r;
@@ -4180,7 +4180,7 @@
     uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
     uint32_t* _to_nxt = _to;
     result r = utf16be_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                               _Maxcode_, _Mode_);
+                               __maxcode_, __mode_);
     frm_nxt = frm + (_frm_nxt - _frm);
     to_nxt = to + (_to_nxt - _to);
     return r;
@@ -4212,14 +4212,14 @@
 {
     const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
     const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
-    return utf16be_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+    return utf16be_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_);
 }
 
 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
 int
 __codecvt_utf16<char32_t, false>::do_max_length() const noexcept
 {
-    if (_Mode_ & consume_header)
+    if (__mode_ & consume_header)
         return 6;
     return 4;
 }
@@ -4239,7 +4239,7 @@
     uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
     uint8_t* _to_nxt = _to;
     result r = ucs4_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                               _Maxcode_, _Mode_);
+                               __maxcode_, __mode_);
     frm_nxt = frm + (_frm_nxt - _frm);
     to_nxt = to + (_to_nxt - _to);
     return r;
@@ -4257,7 +4257,7 @@
     uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
     uint32_t* _to_nxt = _to;
     result r = utf16le_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                               _Maxcode_, _Mode_);
+                               __maxcode_, __mode_);
     frm_nxt = frm + (_frm_nxt - _frm);
     to_nxt = to + (_to_nxt - _to);
     return r;
@@ -4289,14 +4289,14 @@
 {
     const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
     const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
-    return utf16le_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+    return utf16le_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_);
 }
 
 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
 int
 __codecvt_utf16<char32_t, true>::do_max_length() const noexcept
 {
-    if (_Mode_ & consume_header)
+    if (__mode_ & consume_header)
         return 6;
     return 4;
 }
@@ -4323,7 +4323,7 @@
     uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
     uint8_t* _to_nxt = _to;
     result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                             _Maxcode_, _Mode_);
+                             __maxcode_, __mode_);
     frm_nxt = frm + (_frm_nxt - _frm);
     to_nxt = to + (_to_nxt - _to);
     return r;
@@ -4347,7 +4347,7 @@
     uint32_t* _to_nxt = _to;
 #endif
     result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                             _Maxcode_, _Mode_);
+                             __maxcode_, __mode_);
     frm_nxt = frm + (_frm_nxt - _frm);
     to_nxt = to + (_to_nxt - _to);
     return r;
@@ -4379,13 +4379,13 @@
 {
     const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
     const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
-    return utf8_to_utf16_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+    return utf8_to_utf16_length(_frm, _frm_end, mx, __maxcode_, __mode_);
 }
 
 int
 __codecvt_utf8_utf16<wchar_t>::do_max_length() const noexcept
 {
-    if (_Mode_ & consume_header)
+    if (__mode_ & consume_header)
         return 7;
     return 4;
 }
@@ -4405,7 +4405,7 @@
     uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
     uint8_t* _to_nxt = _to;
     result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                             _Maxcode_, _Mode_);
+                             __maxcode_, __mode_);
     frm_nxt = frm + (_frm_nxt - _frm);
     to_nxt = to + (_to_nxt - _to);
     return r;
@@ -4423,7 +4423,7 @@
     uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
     uint16_t* _to_nxt = _to;
     result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                             _Maxcode_, _Mode_);
+                             __maxcode_, __mode_);
     frm_nxt = frm + (_frm_nxt - _frm);
     to_nxt = to + (_to_nxt - _to);
     return r;
@@ -4455,14 +4455,14 @@
 {
     const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
     const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
-    return utf8_to_utf16_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+    return utf8_to_utf16_length(_frm, _frm_end, mx, __maxcode_, __mode_);
 }
 
 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
 int
 __codecvt_utf8_utf16<char16_t>::do_max_length() const noexcept
 {
-    if (_Mode_ & consume_header)
+    if (__mode_ & consume_header)
         return 7;
     return 4;
 }
@@ -4482,7 +4482,7 @@
     uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
     uint8_t* _to_nxt = _to;
     result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                             _Maxcode_, _Mode_);
+                             __maxcode_, __mode_);
     frm_nxt = frm + (_frm_nxt - _frm);
     to_nxt = to + (_to_nxt - _to);
     return r;
@@ -4500,7 +4500,7 @@
     uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
     uint32_t* _to_nxt = _to;
     result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
-                             _Maxcode_, _Mode_);
+                             __maxcode_, __mode_);
     frm_nxt = frm + (_frm_nxt - _frm);
     to_nxt = to + (_to_nxt - _to);
     return r;
@@ -4532,14 +4532,14 @@
 {
     const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
     const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
-    return utf8_to_utf16_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+    return utf8_to_utf16_length(_frm, _frm_end, mx, __maxcode_, __mode_);
 }
 
 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
 int
 __codecvt_utf8_utf16<char32_t>::do_max_length() const noexcept
 {
-    if (_Mode_ & consume_header)
+    if (__mode_ & consume_header)
         return 7;
     return 4;
 }
diff --git a/src/memory.cpp b/src/memory.cpp
index bf96efa..2dcbb35 100644
--- a/src/memory.cpp
+++ b/src/memory.cpp
@@ -152,21 +152,21 @@
 };
 
 _LIBCPP_CONSTEXPR __sp_mut::__sp_mut(void* p) noexcept
-   : __lx(p)
+   : __lx_(p)
 {
 }
 
 void
 __sp_mut::lock() noexcept
 {
-    auto m = static_cast<__libcpp_mutex_t*>(__lx);
+    auto m = static_cast<__libcpp_mutex_t*>(__lx_);
     __libcpp_mutex_lock(m);
 }
 
 void
 __sp_mut::unlock() noexcept
 {
-    __libcpp_mutex_unlock(static_cast<__libcpp_mutex_t*>(__lx));
+    __libcpp_mutex_unlock(static_cast<__libcpp_mutex_t*>(__lx_));
 }
 
 __sp_mut&
diff --git a/src/shared_mutex.cpp b/src/shared_mutex.cpp
index deb3ced..73d4dc1 100644
--- a/src/shared_mutex.cpp
+++ b/src/shared_mutex.cpp
@@ -106,13 +106,13 @@
 
 // Shared Timed Mutex
 // These routines are here for ABI stability
-shared_timed_mutex::shared_timed_mutex() : __base() {}
-void shared_timed_mutex::lock()     { return __base.lock(); }
-bool shared_timed_mutex::try_lock() { return __base.try_lock(); }
-void shared_timed_mutex::unlock()   { return __base.unlock(); }
-void shared_timed_mutex::lock_shared() { return __base.lock_shared(); }
-bool shared_timed_mutex::try_lock_shared() { return __base.try_lock_shared(); }
-void shared_timed_mutex::unlock_shared() { return __base.unlock_shared(); }
+shared_timed_mutex::shared_timed_mutex() : __base_() {}
+void shared_timed_mutex::lock()     { return __base_.lock(); }
+bool shared_timed_mutex::try_lock() { return __base_.try_lock(); }
+void shared_timed_mutex::unlock()   { return __base_.unlock(); }
+void shared_timed_mutex::lock_shared() { return __base_.lock_shared(); }
+bool shared_timed_mutex::try_lock_shared() { return __base_.try_lock_shared(); }
+void shared_timed_mutex::unlock_shared() { return __base_.unlock_shared(); }
 
 _LIBCPP_END_NAMESPACE_STD