[libcxx-commits] [libcxx] c4c0e79 - [libcxx] Add _LIBCPP_NODEBUG to std::conditional related typedfs

David Blaikie via libcxx-commits libcxx-commits at lists.llvm.org
Tue Nov 22 15:38:09 PST 2022


Author: David Blaikie
Date: 2022-11-22T23:37:58Z
New Revision: c4c0e7984ffdef8820eab3e66863e9a598d1d2ef

URL: https://github.com/llvm/llvm-project/commit/c4c0e7984ffdef8820eab3e66863e9a598d1d2ef
DIFF: https://github.com/llvm/llvm-project/commit/c4c0e7984ffdef8820eab3e66863e9a598d1d2ef.diff

LOG: [libcxx] Add _LIBCPP_NODEBUG to std::conditional related typedfs

Looks like std::conditional wasn't included in 14d4869209cc8ff9a53aaa5a59d6409fbc1c5f5d
(& maybe other typedefs that should be using this technique either got
missed or have regressed since that change was made)

This was noticed by a 1.4% clang.dwp regression due to
f4fb72e6d4cee1097e6606e66232fe55e793cd86 introducing more instantiations
of std::conditional - this change reduces that regression to 0.6% at
least.

I'm also looking at other instantiations caused by that change that
might be able to be addressed - but a quick grep shows ~200 "type"
typedefs missing _LIBCPP_NODEBUG, so maybe a systematic application of
the typedef might be suitable?

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

Added: 
    

Modified: 
    libcxx/include/__type_traits/conditional.h

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__type_traits/conditional.h b/libcxx/include/__type_traits/conditional.h
index 4b1a560ddc7c..6249812a1114 100644
--- a/libcxx/include/__type_traits/conditional.h
+++ b/libcxx/include/__type_traits/conditional.h
@@ -36,17 +36,22 @@ template <bool _Cond, class _IfRes, class _ElseRes>
 using _If _LIBCPP_NODEBUG = typename _IfImpl<_Cond>::template _Select<_IfRes, _ElseRes>;
 
 template <bool _Bp, class _If, class _Then>
-    struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;};
+struct _LIBCPP_TEMPLATE_VIS conditional {
+  using type _LIBCPP_NODEBUG = _If;
+};
 template <class _If, class _Then>
-    struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {typedef _Then type;};
+struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {
+  using type _LIBCPP_NODEBUG = _Then;
+};
 
 #if _LIBCPP_STD_VER > 11
 template <bool _Bp, class _IfRes, class _ElseRes>
-using conditional_t = typename conditional<_Bp, _IfRes, _ElseRes>::type;
+using conditional_t _LIBCPP_NODEBUG = typename conditional<_Bp, _IfRes, _ElseRes>::type;
 #endif
 
 // Helper so we can use "conditional_t" in all language versions.
-template <bool _Bp, class _If, class _Then> using __conditional_t = typename conditional<_Bp, _If, _Then>::type;
+template <bool _Bp, class _If, class _Then>
+using __conditional_t _LIBCPP_NODEBUG = typename conditional<_Bp, _If, _Then>::type;
 
 _LIBCPP_END_NAMESPACE_STD
 


        


More information about the libcxx-commits mailing list