forked from OSchip/llvm-project
[libc++] Remove unused variable warnings
Since D100581, Clang started flagging this variable which is set but
never read. Based on comparing this function with __match_at_start_posix_nosubs
(which is very similar), I am pretty confident that `__j` was simply left
behind as an oversight in Howard's 6afe8b0a23
.
Also workaround some unused variable warnings in the <random> tests.
It's pretty lame that we're not asserting the skew and kurtosis of
the binomial and negative binomial distributions, but that should be
tackled separately.
Differential Revision: https://reviews.llvm.org/D103533
This commit is contained in:
parent
6b265f949f
commit
2cf78d4ead
|
@ -5884,7 +5884,6 @@ basic_regex<_CharT, _Traits>::__match_at_start_posix_subs(
|
|||
{
|
||||
vector<__state> __states;
|
||||
__state __best_state;
|
||||
ptrdiff_t __j = 0;
|
||||
ptrdiff_t __highest_j = 0;
|
||||
ptrdiff_t _Np = _VSTD::distance(__first, __last);
|
||||
__node* __st = __start_.get();
|
||||
|
@ -5945,7 +5944,6 @@ basic_regex<_CharT, _Traits>::__match_at_start_posix_subs(
|
|||
__states.pop_back();
|
||||
break;
|
||||
case __state::__accept_and_consume:
|
||||
__j += __s.__current_ - __current;
|
||||
__current = __s.__current_;
|
||||
break;
|
||||
case __state::__repeat:
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
T
|
||||
|
@ -188,24 +186,25 @@ test4()
|
|||
kurtosis += d2 * d2;
|
||||
}
|
||||
var /= u.size();
|
||||
//double dev = std::sqrt(var);
|
||||
double dev = std::sqrt(var);
|
||||
// In this case:
|
||||
// skew computes to 0./0. == nan
|
||||
// kurtosis computes to 0./0. == nan
|
||||
// x_skew == inf
|
||||
// x_kurtosis == inf
|
||||
// These tests are commented out because UBSan warns about division by 0
|
||||
// skew /= u.size() * dev * var;
|
||||
// kurtosis /= u.size() * var * var;
|
||||
// kurtosis -= 3;
|
||||
skew /= u.size() * dev * var;
|
||||
kurtosis /= u.size() * var * var;
|
||||
kurtosis -= 3;
|
||||
double x_mean = d.t() * d.p();
|
||||
double x_var = x_mean*(1-d.p());
|
||||
// double x_skew = (1-2*d.p()) / std::sqrt(x_var);
|
||||
// double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
|
||||
double x_skew = (1-2*d.p()) / std::sqrt(x_var);
|
||||
double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
|
||||
assert(mean == x_mean);
|
||||
assert(var == x_var);
|
||||
// assert(skew == x_skew);
|
||||
// assert(kurtosis == x_kurtosis);
|
||||
// assert(skew == x_skew);
|
||||
(void)skew; (void)x_skew;
|
||||
// assert(kurtosis == x_kurtosis);
|
||||
(void)kurtosis; (void)x_kurtosis;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -237,24 +236,25 @@ test5()
|
|||
kurtosis += d2 * d2;
|
||||
}
|
||||
var /= u.size();
|
||||
// double dev = std::sqrt(var);
|
||||
double dev = std::sqrt(var);
|
||||
// In this case:
|
||||
// skew computes to 0./0. == nan
|
||||
// kurtosis computes to 0./0. == nan
|
||||
// x_skew == -inf
|
||||
// x_kurtosis == inf
|
||||
// These tests are commented out because UBSan warns about division by 0
|
||||
// skew /= u.size() * dev * var;
|
||||
// kurtosis /= u.size() * var * var;
|
||||
// kurtosis -= 3;
|
||||
skew /= u.size() * dev * var;
|
||||
kurtosis /= u.size() * var * var;
|
||||
kurtosis -= 3;
|
||||
double x_mean = d.t() * d.p();
|
||||
double x_var = x_mean*(1-d.p());
|
||||
// double x_skew = (1-2*d.p()) / std::sqrt(x_var);
|
||||
// double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
|
||||
double x_skew = (1-2*d.p()) / std::sqrt(x_var);
|
||||
double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
|
||||
assert(mean == x_mean);
|
||||
assert(var == x_var);
|
||||
// assert(skew == x_skew);
|
||||
// assert(kurtosis == x_kurtosis);
|
||||
// assert(skew == x_skew);
|
||||
(void)skew; (void)x_skew;
|
||||
// assert(kurtosis == x_kurtosis);
|
||||
(void)kurtosis; (void)x_kurtosis;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -390,24 +390,25 @@ test9()
|
|||
kurtosis += d2 * d2;
|
||||
}
|
||||
var /= u.size();
|
||||
// double dev = std::sqrt(var);
|
||||
double dev = std::sqrt(var);
|
||||
// In this case:
|
||||
// skew computes to 0./0. == nan
|
||||
// kurtosis computes to 0./0. == nan
|
||||
// x_skew == inf
|
||||
// x_kurtosis == inf
|
||||
// These tests are commented out because UBSan warns about division by 0
|
||||
// skew /= u.size() * dev * var;
|
||||
// kurtosis /= u.size() * var * var;
|
||||
// kurtosis -= 3;
|
||||
skew /= u.size() * dev * var;
|
||||
kurtosis /= u.size() * var * var;
|
||||
kurtosis -= 3;
|
||||
double x_mean = d.t() * d.p();
|
||||
double x_var = x_mean*(1-d.p());
|
||||
// double x_skew = (1-2*d.p()) / std::sqrt(x_var);
|
||||
// double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
|
||||
double x_skew = (1-2*d.p()) / std::sqrt(x_var);
|
||||
double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
|
||||
assert(mean == x_mean);
|
||||
assert(var == x_var);
|
||||
// assert(skew == x_skew);
|
||||
// assert(kurtosis == x_kurtosis);
|
||||
// assert(skew == x_skew);
|
||||
(void)skew; (void)x_skew;
|
||||
// assert(kurtosis == x_kurtosis);
|
||||
(void)kurtosis; (void)x_kurtosis;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -439,24 +440,25 @@ test10()
|
|||
kurtosis += d2 * d2;
|
||||
}
|
||||
var /= u.size();
|
||||
// double dev = std::sqrt(var);
|
||||
double dev = std::sqrt(var);
|
||||
// In this case:
|
||||
// skew computes to 0./0. == nan
|
||||
// kurtosis computes to 0./0. == nan
|
||||
// x_skew == inf
|
||||
// x_kurtosis == inf
|
||||
// These tests are commented out because UBSan warns about division by 0
|
||||
// skew /= u.size() * dev * var;
|
||||
// kurtosis /= u.size() * var * var;
|
||||
// kurtosis -= 3;
|
||||
skew /= u.size() * dev * var;
|
||||
kurtosis /= u.size() * var * var;
|
||||
kurtosis -= 3;
|
||||
double x_mean = d.t() * d.p();
|
||||
double x_var = x_mean*(1-d.p());
|
||||
// double x_skew = (1-2*d.p()) / std::sqrt(x_var);
|
||||
// double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
|
||||
double x_skew = (1-2*d.p()) / std::sqrt(x_var);
|
||||
double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
|
||||
assert(mean == x_mean);
|
||||
assert(var == x_var);
|
||||
// assert(skew == x_skew);
|
||||
// assert(kurtosis == x_kurtosis);
|
||||
// assert(skew == x_skew);
|
||||
(void)skew; (void)x_skew;
|
||||
// assert(kurtosis == x_kurtosis);
|
||||
(void)kurtosis; (void)x_kurtosis;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -488,24 +490,25 @@ test11()
|
|||
kurtosis += d2 * d2;
|
||||
}
|
||||
var /= u.size();
|
||||
// double dev = std::sqrt(var);
|
||||
double dev = std::sqrt(var);
|
||||
// In this case:
|
||||
// skew computes to 0./0. == nan
|
||||
// kurtosis computes to 0./0. == nan
|
||||
// x_skew == -inf
|
||||
// x_kurtosis == inf
|
||||
// These tests are commented out because UBSan warns about division by 0
|
||||
// skew /= u.size() * dev * var;
|
||||
// kurtosis /= u.size() * var * var;
|
||||
// kurtosis -= 3;
|
||||
skew /= u.size() * dev * var;
|
||||
kurtosis /= u.size() * var * var;
|
||||
kurtosis -= 3;
|
||||
double x_mean = d.t() * d.p();
|
||||
double x_var = x_mean*(1-d.p());
|
||||
// double x_skew = (1-2*d.p()) / std::sqrt(x_var);
|
||||
// double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
|
||||
double x_skew = (1-2*d.p()) / std::sqrt(x_var);
|
||||
double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
|
||||
assert(mean == x_mean);
|
||||
assert(var == x_var);
|
||||
// assert(skew == x_skew);
|
||||
// assert(kurtosis == x_kurtosis);
|
||||
// assert(skew == x_skew);
|
||||
(void)skew; (void)x_skew;
|
||||
// assert(kurtosis == x_kurtosis);
|
||||
(void)kurtosis; (void)x_kurtosis;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
T
|
||||
|
@ -194,10 +192,14 @@ test4()
|
|||
kurtosis -= 3;
|
||||
double x_mean = d.k() * (1 - d.p()) / d.p();
|
||||
double x_var = x_mean / d.p();
|
||||
// double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p()));
|
||||
// double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p()));
|
||||
double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p()));
|
||||
double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p()));
|
||||
assert(mean == x_mean);
|
||||
assert(var == x_var);
|
||||
// assert(skew == x_skew);
|
||||
(void)skew; (void)x_skew;
|
||||
// assert(kurtosis == x_kurtosis);
|
||||
(void)kurtosis; (void)x_kurtosis;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue