[libcxx-commits] [libcxx] 2cf78d4 - [libc++] Remove unused variable warnings
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jun 3 06:43:22 PDT 2021
Author: Louis Dionne
Date: 2021-06-03T09:43:08-04:00
New Revision: 2cf78d4ead4a2ab5375bd6087724211d04119a28
URL: https://github.com/llvm/llvm-project/commit/2cf78d4ead4a2ab5375bd6087724211d04119a28
DIFF: https://github.com/llvm/llvm-project/commit/2cf78d4ead4a2ab5375bd6087724211d04119a28.diff
LOG: [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 <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
Added:
Modified:
libcxx/include/regex
libcxx/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp
libcxx/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/include/regex b/libcxx/include/regex
index dafb0e694a6c6..b046ff28d7bb3 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;
- ptr
diff _t __j = 0;
ptr
diff _t __highest_j = 0;
ptr
diff _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 9b2ba3b4c943f..46a25238ab6ea 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 <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**)
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 6d7d7ea9c78db..2b2adf250524a 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 <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
More information about the libcxx-commits
mailing list