Commit 1966558d authored by Chad Austin's avatar Chad Austin Committed by Facebook Github Bot

enable -Wunused-exception-parameter

Summary:
Build folly with -Werror and -Wunused-exception-parameter to prevent
them from sneaking back in.

Reviewed By: yfeldblum

Differential Revision: D18232483

fbshipit-source-id: 7154d3dfec6c672aa3aa46299456bd3c4d757709
parent 323cd710
...@@ -36,7 +36,7 @@ void loop(int iters) { ...@@ -36,7 +36,7 @@ void loop(int iters) {
for (int i = 0; i < iters * 100; ++i) { for (int i = 0; i < iters * 100; ++i) {
try { try {
recurse(100); recurse(100);
} catch (const std::exception& e) { } catch (const std::exception&) {
folly::exception_tracer::getCurrentExceptions(); folly::exception_tracer::getCurrentExceptions();
} }
} }
......
...@@ -37,11 +37,11 @@ void foo() { ...@@ -37,11 +37,11 @@ void foo() {
try { try {
try { try {
bar(); bar();
} catch (const std::exception& e) { } catch (const std::exception&) {
dumpExceptions("foo: simple catch"); dumpExceptions("foo: simple catch");
bar(); bar();
} }
} catch (const std::exception& e) { } catch (const std::exception&) {
dumpExceptions("foo: catch, exception thrown from previous catch block"); dumpExceptions("foo: catch, exception thrown from previous catch block");
} }
} }
...@@ -54,7 +54,7 @@ void foo() { ...@@ -54,7 +54,7 @@ void foo() {
dumpExceptions("baz: simple catch"); dumpExceptions("baz: simple catch");
throw; throw;
} }
} catch (const std::exception& e) { } catch (const std::exception&) {
dumpExceptions("baz: catch rethrown exception"); dumpExceptions("baz: catch rethrown exception");
throw "hello"; throw "hello";
} }
......
...@@ -2441,7 +2441,7 @@ TEST(FiberManager, swapWithException) { ...@@ -2441,7 +2441,7 @@ TEST(FiberManager, swapWithException) {
fm.addTask([&] { fm.addTask([&] {
try { try {
throw std::logic_error("test"); throw std::logic_error("test");
} catch (const std::exception& e) { } catch (const std::exception&) {
// Ok to call runInMainContext in exception unwinding // Ok to call runInMainContext in exception unwinding
runInMainContext([&] { done = true; }); runInMainContext([&] { done = true; });
} }
...@@ -2453,7 +2453,7 @@ TEST(FiberManager, swapWithException) { ...@@ -2453,7 +2453,7 @@ TEST(FiberManager, swapWithException) {
fm.addTask([&] { fm.addTask([&] {
try { try {
throw std::logic_error("test"); throw std::logic_error("test");
} catch (const std::exception& e) { } catch (const std::exception&) {
Baton b; Baton b;
// Can't block during exception unwinding // Can't block during exception unwinding
ASSERT_DEATH(b.try_wait_for(std::chrono::milliseconds(1)), ""); ASSERT_DEATH(b.try_wait_for(std::chrono::milliseconds(1)), "");
......
...@@ -220,7 +220,7 @@ void throwAndCatchImpl() { ...@@ -220,7 +220,7 @@ void throwAndCatchImpl() {
.then([](Try<Unit>&& t) { .then([](Try<Unit>&& t) {
try { try {
t.value(); t.value();
} catch (const std::runtime_error& e) { } catch (const std::runtime_error&) {
// ... // ...
return; return;
} }
...@@ -255,7 +255,7 @@ void throwWrappedAndCatchImpl() { ...@@ -255,7 +255,7 @@ void throwWrappedAndCatchImpl() {
.then([](Try<Unit>&& t) { .then([](Try<Unit>&& t) {
try { try {
t.value(); t.value();
} catch (const std::runtime_error& e) { } catch (const std::runtime_error&) {
// ... // ...
return; return;
} }
......
...@@ -54,7 +54,7 @@ TEST(UncaughtExceptions, no_uncaught_exception) { ...@@ -54,7 +54,7 @@ TEST(UncaughtExceptions, no_uncaught_exception) {
Validator validator(0, "no_uncaught_exception"); Validator validator(0, "no_uncaught_exception");
try { try {
throw std::runtime_error("exception"); throw std::runtime_error("exception");
} catch (const std::runtime_error& e) { } catch (const std::runtime_error&) {
validator.validate(); validator.validate();
} }
} }
...@@ -63,7 +63,7 @@ TEST(UncaughtExceptions, one_uncaught_exception) { ...@@ -63,7 +63,7 @@ TEST(UncaughtExceptions, one_uncaught_exception) {
try { try {
Validator validator(1, "one_uncaught_exception"); Validator validator(1, "one_uncaught_exception");
throw std::runtime_error("exception"); throw std::runtime_error("exception");
} catch (const std::runtime_error& e) { } catch (const std::runtime_error&) {
} }
} }
...@@ -73,12 +73,12 @@ TEST(UncaughtExceptions, catch_rethrow) { ...@@ -73,12 +73,12 @@ TEST(UncaughtExceptions, catch_rethrow) {
try { try {
Validator validatorInner(1, "catch_rethrow_inner"); Validator validatorInner(1, "catch_rethrow_inner");
throw std::runtime_error("exception"); throw std::runtime_error("exception");
} catch (const std::runtime_error& e) { } catch (const std::runtime_error&) {
EXPECT_EQ(0, folly::uncaught_exceptions()); EXPECT_EQ(0, folly::uncaught_exceptions());
Validator validatorRethrow(1, "catch_rethrow"); Validator validatorRethrow(1, "catch_rethrow");
throw; throw;
} }
} catch (const std::runtime_error& e) { } catch (const std::runtime_error&) {
EXPECT_EQ(0, folly::uncaught_exceptions()); EXPECT_EQ(0, folly::uncaught_exceptions());
} }
} }
...@@ -114,7 +114,7 @@ struct ThrowInDestructor { ...@@ -114,7 +114,7 @@ struct ThrowInDestructor {
N - I + 1, "validating in " + folly::to<std::string>(I)); N - I + 1, "validating in " + folly::to<std::string>(I));
LOG(INFO) << "throwing in ~ThrowInDestructor " << I; LOG(INFO) << "throwing in ~ThrowInDestructor " << I;
throw std::logic_error("inner"); throw std::logic_error("inner");
} catch (const std::logic_error& e) { } catch (const std::logic_error&) {
LOG(INFO) << "catching in ~ThrowInDestructor " << I << " expecting " LOG(INFO) << "catching in ~ThrowInDestructor " << I << " expecting "
<< N - I << ", it is " << folly::uncaught_exceptions(); << N - I << ", it is " << folly::uncaught_exceptions();
EXPECT_EQ(N - I, folly::uncaught_exceptions()); EXPECT_EQ(N - I, folly::uncaught_exceptions());
......
...@@ -372,7 +372,7 @@ class ReadStats { ...@@ -372,7 +372,7 @@ class ReadStats {
size_t messageIndex = 0; size_t messageIndex = 0;
try { try {
parseMessage(msg, &threadID, &messageIndex); parseMessage(msg, &threadID, &messageIndex);
} catch (const std::exception& ex) { } catch (const std::exception&) {
++numUnableToParse_; ++numUnableToParse_;
XLOG(ERR, "unable to parse log message: ", msg); XLOG(ERR, "unable to parse log message: ", msg);
return; return;
......
...@@ -327,7 +327,7 @@ TEST_F(LifoSemTest, shutdown_try_wait_for) { ...@@ -327,7 +327,7 @@ TEST_F(LifoSemTest, shutdown_try_wait_for) {
try { try {
// this is normally 1 second in prod use case. // this is normally 1 second in prod use case.
stopped.try_wait_for(std::chrono::milliseconds(1)); stopped.try_wait_for(std::chrono::milliseconds(1));
} catch (folly::ShutdownSemError& e) { } catch (folly::ShutdownSemError&) {
LOG(INFO) << "try_wait_for shutdown"; LOG(INFO) << "try_wait_for shutdown";
} }
} }
......
...@@ -679,7 +679,7 @@ TEST(Conv, IntToDouble) { ...@@ -679,7 +679,7 @@ TEST(Conv, IntToDouble) {
try { try {
(void)to<float>(957837589847); (void)to<float>(957837589847);
ADD_FAILURE(); ADD_FAILURE();
} catch (std::range_error& e) { } catch (std::range_error&) {
// LOG(INFO) << e.what(); // LOG(INFO) << e.what();
} }
} }
......
...@@ -311,7 +311,7 @@ TEST(ScopeGuard, TEST_SCOPE_FAIL_EXCEPTION_PTR) { ...@@ -311,7 +311,7 @@ TEST(ScopeGuard, TEST_SCOPE_FAIL_EXCEPTION_PTR) {
ep = std::current_exception(); ep = std::current_exception();
} }
std::rethrow_exception(ep); std::rethrow_exception(ep);
} catch (const std::exception& ex) { } catch (const std::exception&) {
catchExecuted = true; catchExecuted = true;
} }
......
...@@ -232,7 +232,7 @@ BENCHMARK(throw_exception, iters) { ...@@ -232,7 +232,7 @@ BENCHMARK(throw_exception, iters) {
for (size_t n = 0; n < iters; ++n) { for (size_t n = 0; n < iters; ++n) {
try { try {
folly::throw_exception<Exception>("this is a test"); folly::throw_exception<Exception>("this is a test");
} catch (const std::exception& ex) { } catch (const std::exception&) {
} }
} }
} }
...@@ -241,7 +241,7 @@ BENCHMARK(catch_no_exception, iters) { ...@@ -241,7 +241,7 @@ BENCHMARK(catch_no_exception, iters) {
for (size_t n = 0; n < iters; ++n) { for (size_t n = 0; n < iters; ++n) {
try { try {
doNothing(); doNothing();
} catch (const std::exception& ex) { } catch (const std::exception&) {
} }
} }
} }
......
...@@ -2863,7 +2863,7 @@ STL_TEST("23.2.3 Table 100.12", at, is_destructible, a) { ...@@ -2863,7 +2863,7 @@ STL_TEST("23.2.3 Table 100.12", at, is_destructible, a) {
try { try {
ca.at(ca.size()); ca.at(ca.size());
FAIL() << "at(size) should have thrown an error"; FAIL() << "at(size) should have thrown an error";
} catch (const std::out_of_range& e) { } catch (const std::out_of_range&) {
} catch (...) { } catch (...) {
FAIL() << "at(size) threw error other than out_of_range"; FAIL() << "at(size) threw error other than out_of_range";
} }
...@@ -2931,7 +2931,7 @@ STL_TEST("23.3.6.3", lengthError, is_move_constructible) { ...@@ -2931,7 +2931,7 @@ STL_TEST("23.3.6.3", lengthError, is_move_constructible) {
try { try {
u.reserve(big); u.reserve(big);
FAIL() << "reserve(big) should have thrown an error"; FAIL() << "reserve(big) should have thrown an error";
} catch (const std::length_error& e) { } catch (const std::length_error&) {
} catch (...) { } catch (...) {
FAIL() << "reserve(big) threw error other than length_error"; FAIL() << "reserve(big) threw error other than length_error";
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment