Skip to content

Commit c231a71

Browse files
committed
Remove LCOV exclusions for lines that could theoretically be taken
1 parent ae9076b commit c231a71

File tree

11 files changed

+21
-47
lines changed

11 files changed

+21
-47
lines changed

include/boost/decimal/charconv.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ constexpr auto to_chars_nonfinite(char* first, char* last, const TargetDecimalTy
190190
}
191191
}
192192

193-
return {last, std::errc::value_too_large}; // LCOV_EXCL_LINE : Should be unreachable
193+
return {last, std::errc::value_too_large};
194194
case FP_NAN:
195195
if (issignaling(value) && buffer_len >= 9)
196196
{
@@ -238,7 +238,7 @@ constexpr auto to_chars_scientific_impl(char* first, char* last, const TargetDec
238238
// Dummy check the bounds
239239
if (BOOST_DECIMAL_UNLIKELY(buffer_size < real_precision))
240240
{
241-
return {last, std::errc::value_too_large}; // LCOV_EXCL_LINE
241+
return {last, std::errc::value_too_large};
242242
}
243243

244244
using uint_type = std::conditional_t<(std::numeric_limits<typename TargetDecimalType::significand_type>::digits >
@@ -253,7 +253,7 @@ constexpr auto to_chars_scientific_impl(char* first, char* last, const TargetDec
253253
// which we have already checked for
254254
if (BOOST_DECIMAL_UNLIKELY(!r))
255255
{
256-
return r; // LCOV_EXCL_LINE
256+
return r;
257257
}
258258

259259
auto current_digits {r.ptr - (first + 1)};
@@ -273,7 +273,7 @@ constexpr auto to_chars_scientific_impl(char* first, char* last, const TargetDec
273273
const auto total_length {total_buffer_length<TargetDecimalType>(static_cast<int>(current_digits), exp, is_neg)};
274274
if (BOOST_DECIMAL_UNLIKELY(total_length > buffer_size))
275275
{
276-
return {last, std::errc::value_too_large}; // LCOV_EXCL_LINE
276+
return {last, std::errc::value_too_large};
277277
}
278278

279279
// Insert our decimal point (or don't in the 1 digit case)
@@ -309,7 +309,7 @@ constexpr auto to_chars_scientific_impl(char* first, char* last, const TargetDec
309309

310310
if (BOOST_DECIMAL_UNLIKELY(!exp_r))
311311
{
312-
return exp_r; // LCOV_EXCL_LINE
312+
return exp_r;
313313
}
314314

315315
return {exp_r.ptr, std::errc{}};
@@ -374,7 +374,7 @@ constexpr auto to_chars_scientific_impl(char* first, char* last, const TargetDec
374374
}
375375
else if (significand_digits > local_precision + 1)
376376
{
377-
const auto original_sig = significand; // LCOV_EXCL_LINE : False negative
377+
const auto original_sig = significand;
378378
fenv_round<TargetDecimalType>(significand);
379379
if (remove_trailing_zeros(original_sig + 1U).trimmed_number == 1U)
380380
{
@@ -406,7 +406,7 @@ constexpr auto to_chars_scientific_impl(char* first, char* last, const TargetDec
406406
// Only real reason we will hit this is a buffer overflow
407407
if (BOOST_DECIMAL_UNLIKELY(!r))
408408
{
409-
return r; // LCOV_EXCL_LINE
409+
return r;
410410
}
411411

412412
const auto current_digits = r.ptr - (first + 1) - 1;
@@ -478,7 +478,7 @@ constexpr auto to_chars_scientific_impl(char* first, char* last, const TargetDec
478478
r = to_chars_integer_impl<int>(first, last, abs_exp);
479479
if (BOOST_DECIMAL_UNLIKELY(!r))
480480
{
481-
return r; // LCOV_EXCL_LINE
481+
return r;
482482
}
483483

484484
return {r.ptr, std::errc()};
@@ -520,7 +520,7 @@ constexpr auto to_chars_fixed_impl(char* first, char* last, const TargetDecimalT
520520

521521
if (BOOST_DECIMAL_UNLIKELY(!r))
522522
{
523-
return r; // LCOV_EXCL_LINE
523+
return r;
524524
}
525525

526526
const auto num_digits {r.ptr - current};
@@ -536,7 +536,7 @@ constexpr auto to_chars_fixed_impl(char* first, char* last, const TargetDecimalT
536536
{
537537
if (BOOST_DECIMAL_UNLIKELY(buffer_size < (current - first) + num_digits + exp))
538538
{
539-
return {last, std::errc::value_too_large}; // LCOV_EXCL_LINE
539+
return {last, std::errc::value_too_large};
540540
}
541541

542542
detail::memset(r.ptr, '0', static_cast<std::size_t>(exp));
@@ -546,7 +546,7 @@ constexpr auto to_chars_fixed_impl(char* first, char* last, const TargetDecimalT
546546
{
547547
if (BOOST_DECIMAL_UNLIKELY(buffer_size < (current - first) + num_digits + 1))
548548
{
549-
return {last, std::errc::value_too_large}; // LCOV_EXCL_LINE
549+
return {last, std::errc::value_too_large};
550550
}
551551

552552
const auto decimal_pos {num_digits - abs_exp};
@@ -560,7 +560,7 @@ constexpr auto to_chars_fixed_impl(char* first, char* last, const TargetDecimalT
560560
const auto leading_zeros {abs_exp - num_digits};
561561
if (BOOST_DECIMAL_UNLIKELY(buffer_size < (current - first) + 2 + leading_zeros + num_digits))
562562
{
563-
return {last, std::errc::value_too_large}; // LCOV_EXCL_LINE
563+
return {last, std::errc::value_too_large};
564564
}
565565

566566
detail::memmove(current + 2 + leading_zeros, current, static_cast<std::size_t>(num_digits));

include/boost/decimal/cstdio.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,8 @@ inline auto snprintf_impl(char* buffer, const std::size_t buf_size, const char*
216216

217217
if (!r)
218218
{
219-
// LCOV_EXCL_START
220219
errno = static_cast<int>(r.ec);
221220
return -1;
222-
// LCOV_EXCL_STOP
223221
}
224222

225223
// Adjust the capitalization and locale
@@ -287,7 +285,6 @@ inline auto fprintf(std::FILE* buffer, const char* format, const T... values) no
287285
}
288286
else
289287
{
290-
// LCOV_EXCL_START
291288
// Add 50% overage in case we need to do locale conversion
292289
std::unique_ptr<char[]> longer_char_buffer(new(std::nothrow) char[(3 * (format_len + value_space + 1)) / 2]);
293290
if (longer_char_buffer == nullptr)
@@ -301,7 +298,6 @@ inline auto fprintf(std::FILE* buffer, const char* format, const T... values) no
301298
{
302299
bytes += static_cast<int>(std::fwrite(longer_char_buffer.get(), sizeof(char), static_cast<std::size_t>(bytes), buffer));
303300
}
304-
// LCOV_EXCL_STOP
305301
}
306302

307303
return bytes;

include/boost/decimal/cstdlib.hpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ inline auto strtod_calculation(const char* str, char** endptr, char* buffer, con
7373
{
7474
if (significand)
7575
{
76-
d = std::numeric_limits<TargetDecimalType>::signaling_NaN(); // LCOV_EXCL_LINE : False negative
76+
d = std::numeric_limits<TargetDecimalType>::signaling_NaN();
7777
}
7878
else
7979
{
@@ -125,11 +125,8 @@ inline auto strtod_impl(const char* str, char** endptr) noexcept -> TargetDecima
125125
std::unique_ptr<char[]> buffer(new(std::nothrow) char[str_length + 1]);
126126
if (buffer == nullptr)
127127
{
128-
// Hard to get coverage on memory exhaustion
129-
// LCOV_EXCL_START
130128
errno = ENOMEM;
131129
return std::numeric_limits<TargetDecimalType>::quiet_NaN();
132-
// LCOV_EXCL_STOP
133130
}
134131

135132
auto d = strtod_calculation<TargetDecimalType>(str, endptr, buffer.get(), str_length);
@@ -148,7 +145,7 @@ inline auto wcstod_calculation(const wchar_t* str, wchar_t** endptr, char* buffe
148145
if (BOOST_DECIMAL_UNLIKELY(val > 255))
149146
{
150147
// Character can not be converted
151-
return std::numeric_limits<TargetDecimalType>::quiet_NaN(); // LCOV_EXCL_LINE
148+
return std::numeric_limits<TargetDecimalType>::quiet_NaN();
152149
}
153150

154151
buffer[i] = static_cast<char>(val);
@@ -188,11 +185,8 @@ inline auto wcstod_impl(const wchar_t* str, wchar_t** endptr) noexcept -> Target
188185
std::unique_ptr<char[]> buffer(new(std::nothrow) char[str_length + 1]);
189186
if (buffer == nullptr)
190187
{
191-
// Hard to get coverage on memory exhaustion
192-
// LCOV_EXCL_START
193188
errno = ENOMEM;
194189
return std::numeric_limits<TargetDecimalType>::quiet_NaN();
195-
// LCOV_EXCL_STOP
196190
}
197191

198192
return wcstod_calculation<TargetDecimalType>(str, endptr, buffer.get(), str_length);

include/boost/decimal/detail/cmath/atan.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ constexpr auto atan_impl(const T x) noexcept
4848
#ifndef BOOST_DECIMAL_FAST_MATH
4949
else if (fpc == FP_INFINITE)
5050
{
51-
result = my_pi_half; // LCOV_EXCL_LINE False negative
51+
result = my_pi_half;
5252
}
5353
#endif
5454
else

include/boost/decimal/detail/cmath/tgamma.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ constexpr auto tgamma_impl(const T x) noexcept
5050
}
5151
else
5252
{
53-
result = x; // LCOV_EXCL_LINE : False negative
53+
result = x;
5454
}
5555
#endif
5656
}
5757
else if (is_pure_int && is_neg)
5858
{
5959
// Pure negative integer argument.
6060
#ifndef BOOST_DECIMAL_FAST_MATH
61-
result = std::numeric_limits<T>::quiet_NaN(); // LCOV_EXCL_LINE : False negative
61+
result = std::numeric_limits<T>::quiet_NaN();
6262
#else
6363
result = T{0};
6464
#endif

include/boost/decimal/detail/fast_float/compute_float80_128.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,8 @@ constexpr auto compute_float80_128(std::int64_t q, const Unsigned_Integer &w,
152152

153153
if (BOOST_DECIMAL_UNLIKELY(ld == std::numeric_limits<long double>::infinity()))
154154
{
155-
// LCOV_EXCL_START
156155
success = false;
157156
ld = 0.0L;
158-
// LCOV_EXCL_STOP
159157
}
160158

161159
return ld;

include/boost/decimal/detail/fenv_rounding.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ constexpr auto coefficient_rounding(T1& coeff, T2& exp, T3& biased_exp, const bo
229229
if (coeff < std::numeric_limits<demoted_integer_type>::max())
230230
{
231231
const auto smaller_coeff {static_cast<demoted_integer_type>(coeff)};
232-
const auto div_res {impl::divmod(smaller_coeff, static_cast<demoted_integer_type>(shift_pow_ten))}; // LCOV_EXCL_LINE : False negative since above and below are hit
232+
const auto div_res {impl::divmod(smaller_coeff, static_cast<demoted_integer_type>(shift_pow_ten))};
233233
shifted_coeff = static_cast<demoted_integer_type>(div_res.quotient);
234234
const auto trailing_digits {div_res.remainder};
235235
sticky = trailing_digits != 0U;

include/boost/decimal/detail/io.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ auto operator>>(std::basic_istream<charT, traits>& is, DecimalType& d)
5151

5252
if (BOOST_DECIMAL_UNLIKELY(t_buffer_len > static_buffer_size))
5353
{
54-
// LCOV_EXCL_START
5554
longer_char_buffer = std::unique_ptr<char[]>(new(std::nothrow) char[t_buffer_len]);
5655
if (longer_char_buffer.get() == nullptr)
5756
{
@@ -60,7 +59,6 @@ auto operator>>(std::basic_istream<charT, traits>& is, DecimalType& d)
6059
}
6160

6261
buffer = longer_char_buffer.get();
63-
// LCOV_EXCL_STOP
6462
}
6563

6664
BOOST_DECIMAL_IF_CONSTEXPR (!std::is_same<charT, char>::value)
@@ -108,7 +106,7 @@ auto operator>>(std::basic_istream<charT, traits>& is, DecimalType& d)
108106

109107
if (BOOST_DECIMAL_UNLIKELY(r.ec == std::errc::not_supported))
110108
{
111-
d = std::numeric_limits<DecimalType>::signaling_NaN(); // LCOV_EXCL_LINE
109+
d = std::numeric_limits<DecimalType>::signaling_NaN();
112110
}
113111
else if (static_cast<int>(r.ec) == EINVAL)
114112
{
@@ -166,7 +164,7 @@ auto operator<<(std::basic_ostream<charT, traits>& os, const DecimalType& d)
166164

167165
if (BOOST_DECIMAL_UNLIKELY(!r))
168166
{
169-
errno = static_cast<int>(r.ec); // LCOV_EXCL_LINE
167+
errno = static_cast<int>(r.ec);
170168
}
171169

172170
*r.ptr = '\0';

include/boost/decimal/detail/parser.hpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,10 @@ constexpr auto parser(const char* first, const char* last, bool& sign, Unsigned_
286286
const from_chars_result r {from_chars_dispatch(significand_buffer, significand_buffer + offset, significand, base)};
287287
switch (r.ec)
288288
{
289-
// The two invalid cases are here for completeness, but I don't think we can actually hit them
290-
// LCOV_EXCL_START
291289
case std::errc::invalid_argument:
292290
return {first, std::errc::invalid_argument};
293291
case std::errc::result_out_of_range:
294292
return {next, std::errc::result_out_of_range};
295-
// LCOV_EXCL_STOP
296293
default:
297294
return {next, std::errc()};
298295
}
@@ -372,11 +369,8 @@ constexpr auto parser(const char* first, const char* last, bool& sign, Unsigned_
372369
const from_chars_result r {from_chars_dispatch(significand_buffer, significand_buffer + offset, significand, base)};
373370
switch (r.ec)
374371
{
375-
// Out of range included for completeness, but I don't think we can actually reach it
376-
// LCOV_EXCL_START
377372
case std::errc::result_out_of_range:
378373
return {next, std::errc::result_out_of_range};
379-
// LCOV_EXCL_STOP
380374
case std::errc::invalid_argument:
381375
return {first, std::errc::invalid_argument};
382376
default:
@@ -418,12 +412,10 @@ constexpr auto parser(const char* first, const char* last, bool& sign, Unsigned_
418412
from_chars_result r = from_chars_dispatch(significand_buffer, significand_buffer + offset, significand, base);
419413
switch (r.ec)
420414
{
421-
// LCOV_EXCL_START
422415
case std::errc::invalid_argument:
423416
return {first, std::errc::invalid_argument};
424417
case std::errc::result_out_of_range:
425418
return {next, std::errc::result_out_of_range};
426-
// LCOV_EXCL_STOP
427419
default:
428420
break;
429421
}

include/boost/decimal/detail/to_float.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,8 @@ BOOST_DECIMAL_CXX20_CONSTEXPR auto to_float(Decimal val) noexcept
9494

9595
if (BOOST_DECIMAL_UNLIKELY(!success))
9696
{
97-
// LCOV_EXCL_START
9897
errno = EINVAL;
9998
return 0;
100-
// LCOV_EXCL_STOP
10199
}
102100

103101
return result;

0 commit comments

Comments
 (0)