From: Louis Dionne Date: Wed, 2 Jun 2021 22:24:28 +0000 (-0400) Subject: [libc++] Remove unused variable warnings X-Git-Tag: llvmorg-14-init~4974 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2cf78d4ead4a2ab5375bd6087724211d04119a28;p=platform%2Fupstream%2Fllvm.git [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 6afe8b0a2336. Also workaround some unused variable warnings in the 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 --- diff --git a/libcxx/include/regex b/libcxx/include/regex index dafb0e6..b046ff2 100644 --- a/libcxx/include/regex +++ b/libcxx/include/regex @@ -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: diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp index 9b2ba3b..46a2523 100644 --- a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp @@ -20,8 +20,6 @@ #include #include -#include "test_macros.h" - template 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**) diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp index 6d7d7ea..2b2adf2 100644 --- a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp @@ -20,8 +20,6 @@ #include #include -#include "test_macros.h" - template 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