Skip to content

Commit 7be243a

Browse files
authored
[NFC][libc++][chrono] Removes dead code. (llvm#132104)
For certain time_points there are specializations of __convert_to_tm. This means the non-specialized version is never called. This means some of the `if constexpr` will never be true. These are removed. Since there is a `static_assert` accidental removal of the specialization will make the code ill-formed.
1 parent d7e7e0a commit 7be243a

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

libcxx/include/__chrono/convert_to_tm.h

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -143,22 +143,16 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& __value) {
143143
# endif
144144

145145
if constexpr (__is_time_point<_ChronoT>) {
146-
if constexpr (same_as<typename _ChronoT::clock, chrono::system_clock>)
147-
return std::__convert_to_tm<_Tm>(__value);
148-
# if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
149-
# if _LIBCPP_HAS_EXPERIMENTAL_TZDB
150-
else if constexpr (same_as<typename _ChronoT::clock, chrono::utc_clock>)
151-
return std::__convert_to_tm<_Tm>(__value);
152-
else if constexpr (same_as<typename _ChronoT::clock, chrono::tai_clock>)
153-
return std::__convert_to_tm<_Tm>(__value);
154-
# endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
155-
# endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
156-
else if constexpr (same_as<typename _ChronoT::clock, chrono::file_clock>)
146+
if constexpr (same_as<typename _ChronoT::clock, chrono::file_clock>)
157147
return std::__convert_to_tm<_Tm>(_ChronoT::clock::to_sys(__value));
158148
else if constexpr (same_as<typename _ChronoT::clock, chrono::local_t>)
159149
return std::__convert_to_tm<_Tm>(chrono::sys_time<typename _ChronoT::duration>{__value.time_since_epoch()});
160-
else
150+
else {
151+
// Note that some clocks have specializations __convert_to_tm for their
152+
// time_point. These don't need to be added here. They do not trigger
153+
// this assert.
161154
static_assert(sizeof(_ChronoT) == 0, "TODO: Add the missing clock specialization");
155+
}
162156
} else if constexpr (chrono::__is_duration_v<_ChronoT>) {
163157
// [time.format]/6
164158
// ... However, if a flag refers to a "time of day" (e.g. %H, %I, %p,

0 commit comments

Comments
 (0)