From 7f22ad99b5c4583d8f579911b8907c7758a4151e Mon Sep 17 00:00:00 2001 From: Igor Sugak Date: Mon, 22 Jun 2015 16:40:19 -0700 Subject: [PATCH] Add missing override and remove redundant virtual in folly Summary: Running clang-tidy to fix this problem, using script D2171334. I noticed that even without this change clang dev build succeeds for folly and opened a separate task to investigate why. Reviewed By: @markisaa Differential Revision: D2179299 --- .../experimental/symbolizer/test/ElfTests.cpp | 3 +- .../symbolizer/test/SymbolizerTest.cpp | 2 +- folly/futures/detail/ThreadWheelTimekeeper.h | 2 +- folly/futures/test/ContextTest.cpp | 2 +- folly/futures/test/ViaTest.cpp | 4 +-- folly/io/async/AsyncSSLSocket.cpp | 13 ++++--- folly/io/async/AsyncServerSocket.cpp | 4 +-- folly/io/async/AsyncSocket.cpp | 2 +- folly/io/async/EventBase.cpp | 4 +-- folly/io/async/test/AsyncSocketTest2.cpp | 12 +++---- folly/io/async/test/AsyncUDPSocketTest.cpp | 18 +++++----- folly/io/async/test/EventBaseBenchmark.cpp | 2 +- folly/io/async/test/EventBaseTest.cpp | 34 +++++++------------ folly/io/test/CompressionTest.cpp | 8 ++--- folly/io/test/IOBufTest.cpp | 2 +- folly/test/ExceptionWrapperTest.cpp | 4 +-- folly/test/PaddedTest.cpp | 4 +-- folly/test/PortabilityTest.cpp | 2 +- .../function_benchmark/test_functions.cpp | 6 ++-- folly/wangle/acceptor/Acceptor.cpp | 23 ++++++------- folly/wangle/bootstrap/BootstrapTest.cpp | 26 ++++++-------- folly/wangle/channel/test/FileRegionTest.cpp | 2 +- folly/wangle/channel/test/PipelineTest.cpp | 4 +-- folly/wangle/codec/CodecTest.cpp | 7 ++-- .../concurrent/IOThreadPoolExecutor.cpp | 6 ++-- .../test/ThreadPoolExecutorTest.cpp | 12 +++---- folly/wangle/service/ServiceTest.cpp | 21 ++++++------ folly/wangle/ssl/test/SSLCacheTest.cpp | 15 ++++---- 28 files changed, 104 insertions(+), 140 deletions(-) diff --git a/folly/experimental/symbolizer/test/ElfTests.cpp b/folly/experimental/symbolizer/test/ElfTests.cpp index b5330b7b..5496e92f 100644 --- a/folly/experimental/symbolizer/test/ElfTests.cpp +++ b/folly/experimental/symbolizer/test/ElfTests.cpp @@ -32,8 +32,7 @@ class ElfTest : public ::testing::Test { ElfTest() : elfFile_(binaryPath.c_str()) { } - virtual ~ElfTest() { - } + ~ElfTest() override {} protected: ElfFile elfFile_; diff --git a/folly/experimental/symbolizer/test/SymbolizerTest.cpp b/folly/experimental/symbolizer/test/SymbolizerTest.cpp index 0cbce4eb..088ae1e7 100644 --- a/folly/experimental/symbolizer/test/SymbolizerTest.cpp +++ b/folly/experimental/symbolizer/test/SymbolizerTest.cpp @@ -64,7 +64,7 @@ void bar() { class ElfCacheTest : public testing::Test { protected: - void SetUp(); + void SetUp() override; }; // Capture "golden" stack trace with default-configured Symbolizer diff --git a/folly/futures/detail/ThreadWheelTimekeeper.h b/folly/futures/detail/ThreadWheelTimekeeper.h index 42f89001..ddbb442d 100644 --- a/folly/futures/detail/ThreadWheelTimekeeper.h +++ b/folly/futures/detail/ThreadWheelTimekeeper.h @@ -31,7 +31,7 @@ class ThreadWheelTimekeeper : public Timekeeper { public: /// But it doesn't *have* to be a singleton. ThreadWheelTimekeeper(); - ~ThreadWheelTimekeeper(); + ~ThreadWheelTimekeeper() override; /// Implement the Timekeeper interface /// This future *does* complete on the timer thread. You should almost diff --git a/folly/futures/test/ContextTest.cpp b/folly/futures/test/ContextTest.cpp index dd29b155..487753aa 100644 --- a/folly/futures/test/ContextTest.cpp +++ b/folly/futures/test/ContextTest.cpp @@ -23,7 +23,7 @@ using namespace folly; class TestData : public RequestData { public: explicit TestData(int data) : data_(data) {} - virtual ~TestData() {} + ~TestData() override {} int data_; }; diff --git a/folly/futures/test/ViaTest.cpp b/folly/futures/test/ViaTest.cpp index 6ed8e29c..053499c3 100644 --- a/folly/futures/test/ViaTest.cpp +++ b/folly/futures/test/ViaTest.cpp @@ -56,7 +56,7 @@ struct ViaFixture : public testing::Test { }); } - ~ViaFixture() { + ~ViaFixture() override { done = true; eastExecutor->add([=]() { }); t.join(); @@ -316,7 +316,7 @@ class ThreadExecutor : public Executor { worker = std::thread(std::bind(&ThreadExecutor::work, this)); } - ~ThreadExecutor() { + ~ThreadExecutor() override { done = true; funcs.write([]{}); worker.join(); diff --git a/folly/io/async/AsyncSSLSocket.cpp b/folly/io/async/AsyncSSLSocket.cpp index f4a44321..7be1983e 100644 --- a/folly/io/async/AsyncSSLSocket.cpp +++ b/folly/io/async/AsyncSSLSocket.cpp @@ -84,8 +84,7 @@ class AsyncSSLSocketConnector: public AsyncSocket::ConnectCallback, int64_t startTime_; protected: - virtual ~AsyncSSLSocketConnector() { - } + ~AsyncSSLSocketConnector() override {} public: AsyncSSLSocketConnector(AsyncSSLSocket *sslSocket, @@ -98,7 +97,7 @@ class AsyncSSLSocketConnector: public AsyncSocket::ConnectCallback, std::chrono::steady_clock::now().time_since_epoch()).count()) { } - virtual void connectSuccess() noexcept { + void connectSuccess() noexcept override { VLOG(7) << "client socket connected"; int64_t timeoutLeft = 0; @@ -118,13 +117,13 @@ class AsyncSSLSocketConnector: public AsyncSocket::ConnectCallback, sslSocket_->sslConn(this, timeoutLeft); } - virtual void connectErr(const AsyncSocketException& ex) noexcept { + void connectErr(const AsyncSocketException& ex) noexcept override { LOG(ERROR) << "TCP connect failed: " << ex.what(); fail(ex); delete this; } - virtual void handshakeSuc(AsyncSSLSocket *sock) noexcept { + void handshakeSuc(AsyncSSLSocket* sock) noexcept override { VLOG(7) << "client handshake success"; if (callback_) { callback_->connectSuccess(); @@ -132,8 +131,8 @@ class AsyncSSLSocketConnector: public AsyncSocket::ConnectCallback, delete this; } - virtual void handshakeErr(AsyncSSLSocket *socket, - const AsyncSocketException& ex) noexcept { + void handshakeErr(AsyncSSLSocket* socket, + const AsyncSocketException& ex) noexcept override { LOG(ERROR) << "client handshakeErr: " << ex.what(); fail(ex); delete this; diff --git a/folly/io/async/AsyncServerSocket.cpp b/folly/io/async/AsyncServerSocket.cpp index 34fa5c6f..b6a28cd0 100644 --- a/folly/io/async/AsyncServerSocket.cpp +++ b/folly/io/async/AsyncServerSocket.cpp @@ -121,9 +121,7 @@ class AsyncServerSocket::BackoffTimeout : public AsyncTimeout { BackoffTimeout(AsyncServerSocket* socket) : AsyncTimeout(socket->getEventBase()), socket_(socket) {} - virtual void timeoutExpired() noexcept { - socket_->backoffTimeoutExpired(); - } + void timeoutExpired() noexcept override { socket_->backoffTimeoutExpired(); } private: AsyncServerSocket* socket_; diff --git a/folly/io/async/AsyncSocket.cpp b/folly/io/async/AsyncSocket.cpp index 20526162..4ab1cdea 100644 --- a/folly/io/async/AsyncSocket.cpp +++ b/folly/io/async/AsyncSocket.cpp @@ -148,7 +148,7 @@ class AsyncSocket::BytesWriteRequest : public AsyncSocket::WriteRequest { } // private destructor, to ensure callers use destroy() - virtual ~BytesWriteRequest() = default; + ~BytesWriteRequest() override = default; const struct iovec* getOps() const { assert(opCount_ > opIndex_); diff --git a/folly/io/async/EventBase.cpp b/folly/io/async/EventBase.cpp index d9016506..b8a1c256 100644 --- a/folly/io/async/EventBase.cpp +++ b/folly/io/async/EventBase.cpp @@ -44,7 +44,7 @@ class FunctionLoopCallback : public EventBase::LoopCallback { explicit FunctionLoopCallback(const Cob& function) : function_(function) {} - virtual void runLoopCallback() noexcept { + void runLoopCallback() noexcept override { function_(); delete this; } @@ -66,7 +66,7 @@ const int kNoFD = -1; class EventBase::FunctionRunner : public NotificationQueue>::Consumer { public: - void messageAvailable(std::pair&& msg) { + void messageAvailable(std::pair&& msg) override { // In libevent2, internal events do not break the loop. // Most users would expect loop(), followed by runInEventBaseThread(), diff --git a/folly/io/async/test/AsyncSocketTest2.cpp b/folly/io/async/test/AsyncSocketTest2.cpp index f44d4fd5..0cdf0876 100644 --- a/folly/io/async/test/AsyncSocketTest2.cpp +++ b/folly/io/async/test/AsyncSocketTest2.cpp @@ -1263,7 +1263,7 @@ class AsyncSocketImmediateRead : public folly::AsyncSocket { bool immediateReadCalled = false; explicit AsyncSocketImmediateRead(folly::EventBase* evb) : AsyncSocket(evb) {} protected: - virtual void checkForImmediateRead() noexcept override { + void checkForImmediateRead() noexcept override { immediateReadCalled = true; AsyncSocket::handleRead(); } @@ -1441,29 +1441,29 @@ class TestAcceptCallback : public AsyncServerSocket::AcceptCallback { acceptStoppedFn_ = fn; } - void connectionAccepted(int fd, const folly::SocketAddress& clientAddr) - noexcept { + void connectionAccepted( + int fd, const folly::SocketAddress& clientAddr) noexcept override { events_.emplace_back(fd, clientAddr); if (connectionAcceptedFn_) { connectionAcceptedFn_(fd, clientAddr); } } - void acceptError(const std::exception& ex) noexcept { + void acceptError(const std::exception& ex) noexcept override { events_.emplace_back(ex.what()); if (acceptErrorFn_) { acceptErrorFn_(ex); } } - void acceptStarted() noexcept { + void acceptStarted() noexcept override { events_.emplace_back(TYPE_START); if (acceptStartedFn_) { acceptStartedFn_(); } } - void acceptStopped() noexcept { + void acceptStopped() noexcept override { events_.emplace_back(TYPE_STOP); if (acceptStoppedFn_) { diff --git a/folly/io/async/test/AsyncUDPSocketTest.cpp b/folly/io/async/test/AsyncUDPSocketTest.cpp index b9f99af1..2af6ffb6 100644 --- a/folly/io/async/test/AsyncUDPSocketTest.cpp +++ b/folly/io/async/test/AsyncUDPSocketTest.cpp @@ -41,16 +41,14 @@ class UDPAcceptor UDPAcceptor(EventBase* evb, int n): evb_(evb), n_(n) { } - void onListenStarted() noexcept { - } + void onListenStarted() noexcept override {} - void onListenStopped() noexcept { - } + void onListenStopped() noexcept override {} void onDataAvailable(std::shared_ptr socket, const folly::SocketAddress& client, std::unique_ptr data, - bool truncated) noexcept { + bool truncated) noexcept override { lastClient_ = client; lastMsg_ = data->moveToFbString().toStdString(); @@ -206,14 +204,14 @@ class UDPClient folly::IOBuf::copyBuffer(folly::to("PING ", n_))); } - void getReadBuffer(void** buf, size_t* len) noexcept { + void getReadBuffer(void** buf, size_t* len) noexcept override { *buf = buf_; *len = 1024; } void onDataAvailable(const folly::SocketAddress& client, size_t len, - bool truncated) noexcept { + bool truncated) noexcept override { VLOG(4) << "Read " << len << " bytes (trun:" << truncated << ") from " << client.describe() << " - " << std::string(buf_, len); VLOG(4) << n_ << " left"; @@ -223,18 +221,18 @@ class UDPClient sendPing(); } - void onReadError(const folly::AsyncSocketException& ex) noexcept { + void onReadError(const folly::AsyncSocketException& ex) noexcept override { VLOG(4) << ex.what(); // Start listening for next PONG socket_->resumeRead(this); } - void onReadClosed() noexcept { + void onReadClosed() noexcept override { CHECK(false) << "We unregister reads before closing"; } - void timeoutExpired() noexcept { + void timeoutExpired() noexcept override { VLOG(4) << "Timeout expired"; sendPing(); } diff --git a/folly/io/async/test/EventBaseBenchmark.cpp b/folly/io/async/test/EventBaseBenchmark.cpp index cbb8b42c..edf39793 100644 --- a/folly/io/async/test/EventBaseBenchmark.cpp +++ b/folly/io/async/test/EventBaseBenchmark.cpp @@ -27,7 +27,7 @@ class CountedLoopCallback : public EventBase::LoopCallback { : eventBase_(eventBase) , count_(count) {} - virtual void runLoopCallback() noexcept { + void runLoopCallback() noexcept override { --count_; if (count_ > 0) { eventBase_->runInLoop(this); diff --git a/folly/io/async/test/EventBaseTest.cpp b/folly/io/async/test/EventBaseTest.cpp index 5e8520ec..40e29d52 100644 --- a/folly/io/async/test/EventBaseTest.cpp +++ b/folly/io/async/test/EventBaseTest.cpp @@ -141,7 +141,7 @@ class TestHandler : public EventHandler { TestHandler(EventBase* eventBase, int fd) : EventHandler(eventBase, fd), fd_(fd) {} - virtual void handlerReady(uint16_t events) noexcept { + void handlerReady(uint16_t events) noexcept override { ssize_t bytesRead = 0; ssize_t bytesWritten = 0; if (events & READ) { @@ -645,7 +645,7 @@ class PartialReadHandler : public TestHandler { PartialReadHandler(EventBase* eventBase, int fd, size_t readLength) : TestHandler(eventBase, fd), fd_(fd), readLength_(readLength) {} - virtual void handlerReady(uint16_t events) noexcept { + void handlerReady(uint16_t events) noexcept override { assert(events == EventHandler::READ); ssize_t bytesRead = readFromFD(fd_, readLength_); log.emplace_back(events, bytesRead, 0); @@ -710,7 +710,7 @@ class PartialWriteHandler : public TestHandler { PartialWriteHandler(EventBase* eventBase, int fd, size_t writeLength) : TestHandler(eventBase, fd), fd_(fd), writeLength_(writeLength) {} - virtual void handlerReady(uint16_t events) noexcept { + void handlerReady(uint16_t events) noexcept override { assert(events == EventHandler::WRITE); ssize_t bytesWritten = writeToFD(fd_, writeLength_); log.emplace_back(events, 0, bytesWritten); @@ -780,9 +780,7 @@ TEST(EventBaseTest, DestroyHandler) { : AsyncTimeout(eb) , handler_(h) {} - virtual void timeoutExpired() noexcept { - delete handler_; - } + void timeoutExpired() noexcept override { delete handler_; } private: EventHandler* handler_; @@ -895,9 +893,7 @@ class TestTimeout : public AsyncTimeout { : AsyncTimeout(eventBase) , timestamp(false) {} - virtual void timeoutExpired() noexcept { - timestamp.reset(); - } + void timeoutExpired() noexcept override { timestamp.reset(); } TimePoint timestamp; }; @@ -933,7 +929,7 @@ class ReschedulingTimeout : public AsyncTimeout { reschedule(); } - virtual void timeoutExpired() noexcept { + void timeoutExpired() noexcept override { timestamps.emplace_back(); reschedule(); } @@ -1052,9 +1048,7 @@ TEST(EventBaseTest, DestroyTimeout) { : AsyncTimeout(eb) , timeout_(t) {} - virtual void timeoutExpired() noexcept { - delete timeout_; - } + void timeoutExpired() noexcept override { delete timeout_; } private: AsyncTimeout* timeout_; @@ -1269,7 +1263,7 @@ class CountedLoopCallback : public EventBase::LoopCallback { , count_(count) , action_(action) {} - virtual void runLoopCallback() noexcept { + void runLoopCallback() noexcept override { --count_; if (count_ > 0) { eventBase_->runInLoop(this); @@ -1437,7 +1431,7 @@ class TerminateTestCallback : public EventBase::LoopCallback, unregisterHandler(); } - virtual void handlerReady(uint16_t events) noexcept { + void handlerReady(uint16_t events) noexcept override { // We didn't register with PERSIST, so we will have been automatically // unregistered already. ASSERT_FALSE(isHandlerRegistered()); @@ -1449,7 +1443,7 @@ class TerminateTestCallback : public EventBase::LoopCallback, eventBase_->runInLoop(this); } - virtual void runLoopCallback() noexcept { + void runLoopCallback() noexcept override { ++loopInvocations_; if (loopInvocations_ >= maxLoopInvocations_) { return; @@ -1526,9 +1520,9 @@ class IdleTimeTimeoutSeries : public AsyncTimeout { scheduleTimeout(1); } - virtual ~IdleTimeTimeoutSeries() {} + ~IdleTimeTimeoutSeries() override {} - void timeoutExpired() noexcept { + void timeoutExpired() noexcept override { ++timeouts_; if(timeout_.empty()){ @@ -1696,9 +1690,7 @@ public: PipeHandler(EventBase* eventBase, int fd) : EventHandler(eventBase, fd) {} - void handlerReady(uint16_t events) noexcept { - abort(); - } + void handlerReady(uint16_t events) noexcept override { abort(); } }; TEST(EventBaseTest, StopBeforeLoop) { diff --git a/folly/io/test/CompressionTest.cpp b/folly/io/test/CompressionTest.cpp index 8fc0ad00..314eba5e 100644 --- a/folly/io/test/CompressionTest.cpp +++ b/folly/io/test/CompressionTest.cpp @@ -133,7 +133,7 @@ TEST(CompressionTestNeedsUncompressedLength, Simple) { class CompressionTest : public testing::TestWithParam> { protected: - void SetUp() { + void SetUp() override { auto tup = GetParam(); uncompressedLength_ = uint64_t(1) << std::tr1::get<0>(tup); codec_ = getCodec(std::tr1::get<1>(tup)); @@ -185,7 +185,7 @@ INSTANTIATE_TEST_CASE_P( class CompressionVarintTest : public testing::TestWithParam> { protected: - void SetUp() { + void SetUp() override { auto tup = GetParam(); uncompressedLength_ = uint64_t(1) << std::tr1::get<0>(tup); codec_ = getCodec(std::tr1::get<1>(tup)); @@ -237,9 +237,7 @@ INSTANTIATE_TEST_CASE_P( class CompressionCorruptionTest : public testing::TestWithParam { protected: - void SetUp() { - codec_ = getCodec(GetParam()); - } + void SetUp() override { codec_ = getCodec(GetParam()); } void runSimpleTest(const DataHolder& dh); diff --git a/folly/io/test/IOBufTest.cpp b/folly/io/test/IOBufTest.cpp index 4e4c1312..4ee43cf2 100644 --- a/folly/io/test/IOBufTest.cpp +++ b/folly/io/test/IOBufTest.cpp @@ -832,7 +832,7 @@ enum BufType { class MoveToFbStringTest : public ::testing::TestWithParam> { protected: - void SetUp() { + void SetUp() override { elementSize_ = std::tr1::get<0>(GetParam()); elementCount_ = std::tr1::get<1>(GetParam()); shared_ = std::tr1::get<2>(GetParam()); diff --git a/folly/test/ExceptionWrapperTest.cpp b/folly/test/ExceptionWrapperTest.cpp index 47b18d2e..79660da3 100644 --- a/folly/test/ExceptionWrapperTest.cpp +++ b/folly/test/ExceptionWrapperTest.cpp @@ -139,8 +139,8 @@ public: explicit IntException(int i) : i_(i) {} - virtual int getInt() const override { return i_; } - virtual const char* what() const noexcept override { + int getInt() const override { return i_; } + const char* what() const noexcept override { what_ = folly::to("int == ", i_); return what_.c_str(); } diff --git a/folly/test/PaddedTest.cpp b/folly/test/PaddedTest.cpp index b3ea1d4a..406d88c0 100644 --- a/folly/test/PaddedTest.cpp +++ b/folly/test/PaddedTest.cpp @@ -84,7 +84,7 @@ class IntPaddedTestBase : public ::testing::Test { class IntPaddedConstTest : public IntPaddedTestBase { protected: - void SetUp() { + void SetUp() override { v_.resize(4); n_ = 0; for (int i = 0; i < 4; i++) { @@ -181,7 +181,7 @@ class StructPaddedTestBase : public ::testing::Test { class StructPaddedConstTest : public StructPaddedTestBase { protected: - void SetUp() { + void SetUp() override { v_.resize(4); n_ = 0; for (int i = 0; i < 4; i++) { diff --git a/folly/test/PortabilityTest.cpp b/folly/test/PortabilityTest.cpp index f6971793..62b25553 100644 --- a/folly/test/PortabilityTest.cpp +++ b/folly/test/PortabilityTest.cpp @@ -28,7 +28,7 @@ class Base { class Derived : public Base { public: - virtual int foo() const FOLLY_FINAL { return 2; } + int foo() const FOLLY_FINAL { return 2; } }; // A compiler that supports final will likely inline the call to p->foo() diff --git a/folly/test/function_benchmark/test_functions.cpp b/folly/test/function_benchmark/test_functions.cpp index ed34257a..8eaf51a4 100644 --- a/folly/test/function_benchmark/test_functions.cpp +++ b/folly/test/function_benchmark/test_functions.cpp @@ -25,11 +25,9 @@ class Exception : public std::exception { public: explicit Exception(const std::string& value) : value_(value) {} - virtual ~Exception(void) noexcept {} + ~Exception(void) noexcept override {} - virtual const char *what(void) const noexcept { - return value_.c_str(); - } + const char* what(void) const noexcept override { return value_.c_str(); } private: std::string value_; diff --git a/folly/wangle/acceptor/Acceptor.cpp b/folly/wangle/acceptor/Acceptor.cpp index 8ef0d18b..f66b3412 100644 --- a/folly/wangle/acceptor/Acceptor.cpp +++ b/folly/wangle/acceptor/Acceptor.cpp @@ -69,30 +69,27 @@ class AcceptorHandshakeHelper : socket_->sslAccept(this); } - virtual void timeoutExpired() noexcept override { + void timeoutExpired() noexcept override { VLOG(4) << "SSL handshake timeout expired"; sslError_ = SSLErrorEnum::TIMEOUT; dropConnection(); } - virtual void describe(std::ostream& os) const override { + void describe(std::ostream& os) const override { os << "pending handshake on " << clientAddr_; } - virtual bool isBusy() const override { - return true; - } - virtual void notifyPendingShutdown() override {} - virtual void closeWhenIdle() override {} + bool isBusy() const override { return true; } + void notifyPendingShutdown() override {} + void closeWhenIdle() override {} - virtual void dropConnection() override { + void dropConnection() override { VLOG(10) << "Dropping in progress handshake for " << clientAddr_; socket_->closeNow(); } - virtual void dumpConnectionState(uint8_t loglevel) override { - } + void dumpConnectionState(uint8_t loglevel) override {} private: // AsyncSSLSocket::HandshakeCallback API - virtual void handshakeSuc(AsyncSSLSocket* sock) noexcept override { + void handshakeSuc(AsyncSSLSocket* sock) noexcept override { const unsigned char* nextProto = nullptr; unsigned nextProtoLength = 0; @@ -146,8 +143,8 @@ class AcceptorHandshakeHelper : delete this; } - virtual void handshakeErr(AsyncSSLSocket* sock, - const AsyncSocketException& ex) noexcept override { + void handshakeErr(AsyncSSLSocket* sock, + const AsyncSocketException& ex) noexcept override { auto elapsedTime = std::chrono::duration_cast(std::chrono::steady_clock::now() - acceptTime_); VLOG(3) << "SSL handshake error after " << elapsedTime.count() << " ms; " << sock->getRawBytesReceived() << " bytes received & " << diff --git a/folly/wangle/bootstrap/BootstrapTest.cpp b/folly/wangle/bootstrap/BootstrapTest.cpp index 724afec9..ad82738d 100644 --- a/folly/wangle/bootstrap/BootstrapTest.cpp +++ b/folly/wangle/bootstrap/BootstrapTest.cpp @@ -33,7 +33,7 @@ typedef ClientBootstrap TestClient; class TestClientPipelineFactory : public PipelineFactory { public: std::unique_ptr - newPipeline(std::shared_ptr sock) { + newPipeline(std::shared_ptr sock) override { // We probably aren't connected immedately, check after a small delay EventBaseManager::get()->getEventBase()->tryRunAfterDelay([sock](){ CHECK(sock->good()); @@ -45,8 +45,8 @@ class TestClientPipelineFactory : public PipelineFactory { class TestPipelineFactory : public PipelineFactory { public: - std::unique_ptr newPipeline( - std::shared_ptr sock) { + std::unique_ptr + newPipeline(std::shared_ptr sock) override { pipelines++; return std::unique_ptr( @@ -61,17 +61,15 @@ EventBase base_; TestAcceptor() : Acceptor(ServerSocketConfig()) { Acceptor::init(nullptr, &base_); } - void onNewConnection( - AsyncSocket::UniquePtr sock, - const folly::SocketAddress* address, - const std::string& nextProtocolName, - const TransportInfo& tinfo) { - } + void onNewConnection(AsyncSocket::UniquePtr sock, + const folly::SocketAddress* address, + const std::string& nextProtocolName, + const TransportInfo& tinfo) override {} }; class TestAcceptorFactory : public AcceptorFactory { public: - std::shared_ptr newAcceptor(EventBase* base) { + std::shared_ptr newAcceptor(EventBase* base) override { return std::make_shared(); } }; @@ -272,7 +270,7 @@ std::atomic connections{0}; class TestHandlerPipeline : public InboundHandler { public: - void read(Context* ctx, void* conn) { + void read(Context* ctx, void* conn) override { connections++; return ctx->fireRead(conn); } @@ -284,7 +282,7 @@ class TestHandlerPipelineFactory public: std::unique_ptr::AcceptPipeline, folly::DelayedDestruction::Destructor> - newPipeline(std::shared_ptr) { + newPipeline(std::shared_ptr) override { std::unique_ptr::AcceptPipeline, folly::DelayedDestruction::Destructor> pipeline( @@ -320,9 +318,7 @@ TEST(Bootstrap, LoadBalanceHandler) { class TestUDPPipeline : public InboundHandler { public: - void read(Context* ctx, void* conn) { - connections++; - } + void read(Context* ctx, void* conn) override { connections++; } }; TEST(Bootstrap, UDP) { diff --git a/folly/wangle/channel/test/FileRegionTest.cpp b/folly/wangle/channel/test/FileRegionTest.cpp index ff12fc2f..965743dd 100644 --- a/folly/wangle/channel/test/FileRegionTest.cpp +++ b/folly/wangle/channel/test/FileRegionTest.cpp @@ -38,7 +38,7 @@ struct FileRegionTest : public Test { EXPECT_EQ(0, unlink(path)); } - ~FileRegionTest() { + ~FileRegionTest() override { // Close up shop close(fd); acceptedSocket->close(); diff --git a/folly/wangle/channel/test/PipelineTest.cpp b/folly/wangle/channel/test/PipelineTest.cpp index 36c4cee6..84a25584 100644 --- a/folly/wangle/channel/test/PipelineTest.cpp +++ b/folly/wangle/channel/test/PipelineTest.cpp @@ -265,8 +265,8 @@ template class ConcreteHandler : public Handler { typedef typename Handler::Context Context; public: - void read(Context* ctx, Rin msg) {} - Future write(Context* ctx, Win msg) { return makeFuture(); } + void read(Context* ctx, Rin msg) override {} + Future write(Context* ctx, Win msg) override { return makeFuture(); } }; typedef HandlerAdapter StringHandler; diff --git a/folly/wangle/codec/CodecTest.cpp b/folly/wangle/codec/CodecTest.cpp index ecca824f..25ff2fea 100644 --- a/folly/wangle/codec/CodecTest.cpp +++ b/folly/wangle/codec/CodecTest.cpp @@ -30,11 +30,11 @@ class FrameTester explicit FrameTester(std::function)> test) : test_(test) {} - void read(Context* ctx, std::unique_ptr buf) { + void read(Context* ctx, std::unique_ptr buf) override { test_(std::move(buf)); } - void readException(Context* ctx, exception_wrapper w) { + void readException(Context* ctx, exception_wrapper w) override { test_(nullptr); } private: @@ -44,8 +44,7 @@ class FrameTester class BytesReflector : public BytesToBytesHandler { public: - - Future write(Context* ctx, std::unique_ptr buf) { + Future write(Context* ctx, std::unique_ptr buf) override { IOBufQueue q_(IOBufQueue::cacheChainLength()); q_.append(std::move(buf)); ctx->fireRead(q_); diff --git a/folly/wangle/concurrent/IOThreadPoolExecutor.cpp b/folly/wangle/concurrent/IOThreadPoolExecutor.cpp index 7552cad9..91f32842 100644 --- a/folly/wangle/concurrent/IOThreadPoolExecutor.cpp +++ b/folly/wangle/concurrent/IOThreadPoolExecutor.cpp @@ -33,11 +33,9 @@ class MemoryIdlerTimeout public: explicit MemoryIdlerTimeout(EventBase* b) : AsyncTimeout(b), base_(b) {} - virtual void timeoutExpired() noexcept { - idled = true; - } + void timeoutExpired() noexcept override { idled = true; } - virtual void runLoopCallback() noexcept { + void runLoopCallback() noexcept override { if (idled) { MemoryIdler::flushLocalMallocCaches(); MemoryIdler::unmapUnusedStack(MemoryIdler::kDefaultStackToRetain); diff --git a/folly/wangle/concurrent/test/ThreadPoolExecutorTest.cpp b/folly/wangle/concurrent/test/ThreadPoolExecutorTest.cpp index 8a6fcc02..59c28c01 100644 --- a/folly/wangle/concurrent/test/ThreadPoolExecutorTest.cpp +++ b/folly/wangle/concurrent/test/ThreadPoolExecutorTest.cpp @@ -322,16 +322,12 @@ TEST(ThreadPoolExecutorTest, PriorityPreemptionTest) { class TestObserver : public ThreadPoolExecutor::Observer { public: - void threadStarted(ThreadPoolExecutor::ThreadHandle*) { + void threadStarted(ThreadPoolExecutor::ThreadHandle*) override { threads_++; } + void threadStopped(ThreadPoolExecutor::ThreadHandle*) override { threads_--; } + void threadPreviouslyStarted(ThreadPoolExecutor::ThreadHandle*) override { threads_++; } - void threadStopped(ThreadPoolExecutor::ThreadHandle*) { - threads_--; - } - void threadPreviouslyStarted(ThreadPoolExecutor::ThreadHandle*) { - threads_++; - } - void threadNotYetStopped(ThreadPoolExecutor::ThreadHandle*) { + void threadNotYetStopped(ThreadPoolExecutor::ThreadHandle*) override { threads_--; } void checkCalls() { diff --git a/folly/wangle/service/ServiceTest.cpp b/folly/wangle/service/ServiceTest.cpp index 4bf37df8..93da3e2d 100644 --- a/folly/wangle/service/ServiceTest.cpp +++ b/folly/wangle/service/ServiceTest.cpp @@ -29,22 +29,21 @@ typedef Pipeline ServicePipeline; class SimpleDecode : public ByteToMessageCodec { public: - virtual std::unique_ptr decode( - Context* ctx, IOBufQueue& buf, size_t&) { + std::unique_ptr decode(Context* ctx, + IOBufQueue& buf, + size_t&) override { return buf.move(); } }; class EchoService : public Service { public: - virtual Future operator()(std::string req) override { - return req; - } + Future operator()(std::string req) override { return req; } }; class EchoIntService : public Service { public: - virtual Future operator()(std::string req) override { + Future operator()(std::string req) override { return folly::to(req); } }; @@ -143,7 +142,7 @@ class AppendFilter : public ServiceFilter { std::shared_ptr> service) : ServiceFilter(service) {} - virtual Future operator()(std::string req) { + Future operator()(std::string req) override { return (*service_)(req + "\n"); } }; @@ -155,7 +154,7 @@ class IntToStringFilter std::shared_ptr> service) : ServiceFilter(service) {} - virtual Future operator()(int req) { + Future operator()(int req) override { return (*service_)(folly::to(req)).then([](std::string resp) { return folly::to(resp); }); @@ -183,7 +182,7 @@ class ChangeTypeFilter std::shared_ptr> service) : ServiceFilter(service) {} - virtual Future operator()(int req) { + Future operator()(int req) override { return (*service_)(folly::to(req)).then([](int resp) { return folly::to(resp); }); @@ -204,8 +203,8 @@ class ConnectionCountFilter : public ServiceFactoryFilter { std::shared_ptr> factory) : ServiceFactoryFilter(factory) {} - virtual Future>> operator()( - std::shared_ptr> client) { + Future>> operator()( + std::shared_ptr> client) override { connectionCount++; return (*this->serviceFactory_)(client); } diff --git a/folly/wangle/ssl/test/SSLCacheTest.cpp b/folly/wangle/ssl/test/SSLCacheTest.cpp index f3129e48..24f80518 100644 --- a/folly/wangle/ssl/test/SSLCacheTest.cpp +++ b/folly/wangle/ssl/test/SSLCacheTest.cpp @@ -60,7 +60,7 @@ private: public: SSLCacheClient(EventBase* eventBase, SSL_SESSION **pSess, ClientRunner* cr); - ~SSLCacheClient() { + ~SSLCacheClient() override { if (session_ && !FLAGS_global) SSL_SESSION_free(session_); if (socket_ != nullptr) { @@ -75,17 +75,14 @@ public: void start(); - virtual void connectSuccess() noexcept; + void connectSuccess() noexcept override; - virtual void connectErr(const AsyncSocketException& ex) - noexcept ; + void connectErr(const AsyncSocketException& ex) noexcept override; - virtual void handshakeSuc(AsyncSSLSocket* sock) noexcept; - - virtual void handshakeErr( - AsyncSSLSocket* sock, - const AsyncSocketException& ex) noexcept; + void handshakeSuc(AsyncSSLSocket* sock) noexcept override; + void handshakeErr(AsyncSSLSocket* sock, + const AsyncSocketException& ex) noexcept override; }; int -- 2.34.1