From: Jim Meyering Date: Fri, 13 Feb 2015 18:36:27 +0000 (-0800) Subject: folly: avoid new warnings from -Winconsistent-missing-override X-Git-Tag: v0.27.0~43 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ccb229d557f1d137473bd256739b379ffdd139e8;p=folly.git folly: avoid new warnings from -Winconsistent-missing-override Summary: Upgrading to clang:dev (clang >3.6) brought in some new warnings. This change address all of the issues exposed by the new -Winconsistent-missing-override, usually by simply adding the missing "override" keyword. However, in folly/wangle/channel/test/MockChannelHandler.h, I chose to ignore those warnings for the mocked functions. * folly/futures/test/ViaTest.cpp: Add missing "override"(s). * folly/io/async/AsyncSSLSocket.h: Likewise. * folly/io/async/AsyncSocket.h: Likewise. * folly/io/async/EventBase.h: Likewise. * folly/test/ExceptionWrapperTest.cpp: Likewise. * folly/wangle/channel/AsyncSocketHandler.h: Likewise. * folly/wangle/channel/test/MockChannelHandler.h: Ignore the new warning for these functions. Test Plan: Run these commands and note there are fewer errors than before: fbconfig --clang --with-project-version=clang:dev -r folly && fbmake dbgo Reviewed By: hans@fb.com Subscribers: trunkagent, fugalh, folly-diffs@, jsedgwick, yfeldblum FB internal diff: D1848330 Tasks: 6244745 Signature: t1:1848330:1423858909:b167ca220d6c9fe036d3adca08cf3053a7a9de16 --- diff --git a/folly/futures/test/ViaTest.cpp b/folly/futures/test/ViaTest.cpp index 4a78ce7d..d203c18c 100644 --- a/folly/futures/test/ViaTest.cpp +++ b/folly/futures/test/ViaTest.cpp @@ -27,7 +27,7 @@ using namespace folly; struct ManualWaiter : public DrivableExecutor { explicit ManualWaiter(std::shared_ptr ex) : ex(ex) {} - void add(Func f) { + void add(Func f) override { ex->add(f); } diff --git a/folly/io/async/AsyncSSLSocket.h b/folly/io/async/AsyncSSLSocket.h index 8f3c8bd0..ec8f700e 100644 --- a/folly/io/async/AsyncSSLSocket.h +++ b/folly/io/async/AsyncSSLSocket.h @@ -263,16 +263,16 @@ class AsyncSSLSocket : public virtual AsyncSocket { // See the documentation in TAsyncTransport.h // TODO: implement graceful shutdown in close() // TODO: implement detachSSL() that returns the SSL connection - virtual void closeNow(); - virtual void shutdownWrite(); - virtual void shutdownWriteNow(); - virtual bool good() const; - virtual bool connecting() const; + virtual void closeNow() override; + virtual void shutdownWrite() override; + virtual void shutdownWriteNow() override; + virtual bool good() const override; + virtual bool connecting() const override; bool isEorTrackingEnabled() const override; - virtual void setEorTracking(bool track); - virtual size_t getRawBytesWritten() const; - virtual size_t getRawBytesReceived() const; + virtual void setEorTracking(bool track) override; + virtual size_t getRawBytesWritten() const override; + virtual size_t getRawBytesReceived() const override; void enableClientHelloParsing(); /** @@ -309,7 +309,7 @@ class AsyncSSLSocket : public virtual AsyncSocket { int timeout = 0, const OptionMap &options = emptyOptionMap, const folly::SocketAddress& bindAddr = anyAddress) - noexcept; + noexcept override; using AsyncSocket::connect; @@ -469,12 +469,12 @@ class AsyncSSLSocket : public virtual AsyncSocket { return 0; } - virtual void attachEventBase(EventBase* eventBase) { + virtual void attachEventBase(EventBase* eventBase) override { AsyncSocket::attachEventBase(eventBase); handshakeTimeout_.attachEventBase(eventBase); } - virtual void detachEventBase() { + virtual void detachEventBase() override { AsyncSocket::detachEventBase(); handshakeTimeout_.detachEventBase(); } @@ -654,21 +654,22 @@ class AsyncSSLSocket : public virtual AsyncSocket { // Inherit event notification methods from AsyncSocket except // the following. - void handleRead() noexcept; - void handleWrite() noexcept; + void handleRead() noexcept override; + void handleWrite() noexcept override; void handleAccept() noexcept; - void handleConnect() noexcept; + void handleConnect() noexcept override; void invalidState(HandshakeCB* callback); bool willBlock(int ret, int *errorOut) noexcept; - virtual void checkForImmediateRead() noexcept; + virtual void checkForImmediateRead() noexcept override; // AsyncSocket calls this at the wrong time for SSL - void handleInitialReadWrite() noexcept {} + void handleInitialReadWrite() noexcept override {} - ssize_t performRead(void* buf, size_t buflen); + ssize_t performRead(void* buf, size_t buflen) override; ssize_t performWrite(const iovec* vec, uint32_t count, WriteFlags flags, - uint32_t* countWritten, uint32_t* partialWritten); + uint32_t* countWritten, uint32_t* partialWritten) + override; // This virtual wrapper around SSL_write exists solely for testing/mockability virtual int sslWriteImpl(SSL *ssl, const void *buf, int n) { diff --git a/folly/io/async/AsyncSocket.h b/folly/io/async/AsyncSocket.h index 10614abf..b8b23016 100644 --- a/folly/io/async/AsyncSocket.h +++ b/folly/io/async/AsyncSocket.h @@ -186,7 +186,7 @@ class AsyncSocket : virtual public AsyncTransportWrapper { * This prevents callers from deleting a AsyncSocket while it is invoking a * callback. */ - virtual void destroy(); + virtual void destroy() override; /** * Get the EventBase used by this socket. diff --git a/folly/io/async/EventBase.h b/folly/io/async/EventBase.h index 390ee243..a4051dfe 100644 --- a/folly/io/async/EventBase.h +++ b/folly/io/async/EventBase.h @@ -454,7 +454,7 @@ class EventBase : private boost::noncopyable, * first handler fired within that cycle. * */ - bool bumpHandlingTime(); + bool bumpHandlingTime() override; class SmoothLoopTime { public: @@ -519,15 +519,16 @@ class EventBase : private boost::noncopyable, // TimeoutManager void attachTimeoutManager(AsyncTimeout* obj, - TimeoutManager::InternalEnum internal); + TimeoutManager::InternalEnum internal) override; - void detachTimeoutManager(AsyncTimeout* obj); + void detachTimeoutManager(AsyncTimeout* obj) override; - bool scheduleTimeout(AsyncTimeout* obj, std::chrono::milliseconds timeout); + bool scheduleTimeout(AsyncTimeout* obj, std::chrono::milliseconds timeout) + override; - void cancelTimeout(AsyncTimeout* obj); + void cancelTimeout(AsyncTimeout* obj) override; - bool isInTimeoutManagerThread() { + bool isInTimeoutManagerThread() override { return isInEventBaseThread(); } diff --git a/folly/test/ExceptionWrapperTest.cpp b/folly/test/ExceptionWrapperTest.cpp index bfeac2bc..96b09334 100644 --- a/folly/test/ExceptionWrapperTest.cpp +++ b/folly/test/ExceptionWrapperTest.cpp @@ -139,7 +139,7 @@ public: explicit IntException(int i) : i_(i) {} - virtual int getInt() const { return i_; } + virtual int getInt() const override { return i_; } virtual const char* what() const noexcept override { what_ = folly::to("int == ", i_); return what_.c_str(); diff --git a/folly/wangle/channel/AsyncSocketHandler.h b/folly/wangle/channel/AsyncSocketHandler.h index 46fb03b8..e4bb98ee 100644 --- a/folly/wangle/channel/AsyncSocketHandler.h +++ b/folly/wangle/channel/AsyncSocketHandler.h @@ -89,7 +89,7 @@ class AsyncSocketHandler return future; }; - folly::Future close(Context* ctx) { + folly::Future close(Context* ctx) override { if (socket_) { detachReadCallback(); socket_->closeNow(); diff --git a/folly/wangle/channel/test/MockChannelHandler.h b/folly/wangle/channel/test/MockChannelHandler.h index 0c666d94..93086704 100644 --- a/folly/wangle/channel/test/MockChannelHandler.h +++ b/folly/wangle/channel/test/MockChannelHandler.h @@ -29,6 +29,11 @@ class MockChannelHandler : public ChannelHandler { MockChannelHandler() = default; MockChannelHandler(MockChannelHandler&&) = default; +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Winconsistent-missing-override" +#endif + MOCK_METHOD2_T(read_, void(Context*, Rin&)); MOCK_METHOD1_T(readEOF, void(Context*)); MOCK_METHOD2_T(readException, void(Context*, exception_wrapper)); @@ -41,7 +46,11 @@ class MockChannelHandler : public ChannelHandler { MOCK_METHOD1_T(detachPipeline, void(Context*)); MOCK_METHOD1_T(detachTransport, void(Context*)); - void read(Context* ctx, Rin msg) { +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + + void read(Context* ctx, Rin msg) override { read_(ctx, msg); }