Skip to content

Commit 7230f5c

Browse files
committed
Suppress cppcheck's broken AST parser warnings
1 parent d01e283 commit 7230f5c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

tinyexpr.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2368,6 +2368,7 @@ auto make_function_arg_list(const F& func, std::index_sequence<Indices...>)
23682368
return std::make_tuple(func(Indices)...);
23692369
}
23702370

2371+
// cppcheck-suppress-begin all
23712372
te_type te_parser::te_eval(const te_expr* texp)
23722373
{
23732374
if (texp == nullptr)
@@ -2376,7 +2377,6 @@ te_type te_parser::te_eval(const te_expr* texp)
23762377
}
23772378

23782379
// NOLINTBEGIN
2379-
// cppcheck-suppress unreadVariable
23802380
const auto M = [&texp = std::as_const(texp)](const size_t e)
23812381
{ return (e < texp->m_parameters.size()) ? te_eval(texp->m_parameters[e]) : te_nan; };
23822382

@@ -2388,27 +2388,27 @@ te_type te_parser::te_eval(const te_expr* texp)
23882388
{
23892389
return var;
23902390
}
2391-
else if constexpr (te_is_variable_v<T>)
2391+
if constexpr (te_is_variable_v<T>)
23922392
{
23932393
return *var;
23942394
}
2395-
else if constexpr (std::is_same_v<T, te_fun0>)
2395+
if constexpr (std::is_same_v<T, te_fun0>)
23962396
{
23972397
return var();
23982398
}
2399-
else if constexpr (std::is_same_v<T, te_confun0>)
2399+
if constexpr (std::is_same_v<T, te_confun0>)
24002400
{
24012401
return var(texp->m_parameters[0]);
24022402
}
2403-
else if constexpr (te_is_closure_v<T>)
2403+
if constexpr (te_is_closure_v<T>)
24042404
{
24052405
constexpr size_t n_args = te_function_arity<T>;
24062406
static_assert(n_args > 0);
24072407
return std::apply(var,
24082408
make_closure_arg_list(M, texp->m_parameters[n_args - 1],
24092409
std::make_index_sequence<n_args - 1>{}));
24102410
}
2411-
else if constexpr (te_is_function_v<T>)
2411+
if constexpr (te_is_function_v<T>)
24122412
{
24132413
constexpr size_t n_args = te_function_arity<T>;
24142414
return std::apply(var,
@@ -2420,6 +2420,8 @@ te_type te_parser::te_eval(const te_expr* texp)
24202420
// NOLINTEND
24212421
}
24222422

2423+
// cppcheck-suppress-end all
2424+
24232425
//--------------------------------------------------
24242426
void te_parser::optimize(te_expr* texp)
24252427
{

0 commit comments

Comments
 (0)