Commit ccb229d5 authored by Jim Meyering's avatar Jim Meyering Committed by Alecs King

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
parent 09430395
...@@ -27,7 +27,7 @@ using namespace folly; ...@@ -27,7 +27,7 @@ using namespace folly;
struct ManualWaiter : public DrivableExecutor { struct ManualWaiter : public DrivableExecutor {
explicit ManualWaiter(std::shared_ptr<ManualExecutor> ex) : ex(ex) {} explicit ManualWaiter(std::shared_ptr<ManualExecutor> ex) : ex(ex) {}
void add(Func f) { void add(Func f) override {
ex->add(f); ex->add(f);
} }
......
...@@ -263,16 +263,16 @@ class AsyncSSLSocket : public virtual AsyncSocket { ...@@ -263,16 +263,16 @@ class AsyncSSLSocket : public virtual AsyncSocket {
// See the documentation in TAsyncTransport.h // See the documentation in TAsyncTransport.h
// TODO: implement graceful shutdown in close() // TODO: implement graceful shutdown in close()
// TODO: implement detachSSL() that returns the SSL connection // TODO: implement detachSSL() that returns the SSL connection
virtual void closeNow(); virtual void closeNow() override;
virtual void shutdownWrite(); virtual void shutdownWrite() override;
virtual void shutdownWriteNow(); virtual void shutdownWriteNow() override;
virtual bool good() const; virtual bool good() const override;
virtual bool connecting() const; virtual bool connecting() const override;
bool isEorTrackingEnabled() const override; bool isEorTrackingEnabled() const override;
virtual void setEorTracking(bool track); virtual void setEorTracking(bool track) override;
virtual size_t getRawBytesWritten() const; virtual size_t getRawBytesWritten() const override;
virtual size_t getRawBytesReceived() const; virtual size_t getRawBytesReceived() const override;
void enableClientHelloParsing(); void enableClientHelloParsing();
/** /**
...@@ -309,7 +309,7 @@ class AsyncSSLSocket : public virtual AsyncSocket { ...@@ -309,7 +309,7 @@ class AsyncSSLSocket : public virtual AsyncSocket {
int timeout = 0, int timeout = 0,
const OptionMap &options = emptyOptionMap, const OptionMap &options = emptyOptionMap,
const folly::SocketAddress& bindAddr = anyAddress) const folly::SocketAddress& bindAddr = anyAddress)
noexcept; noexcept override;
using AsyncSocket::connect; using AsyncSocket::connect;
...@@ -469,12 +469,12 @@ class AsyncSSLSocket : public virtual AsyncSocket { ...@@ -469,12 +469,12 @@ class AsyncSSLSocket : public virtual AsyncSocket {
return 0; return 0;
} }
virtual void attachEventBase(EventBase* eventBase) { virtual void attachEventBase(EventBase* eventBase) override {
AsyncSocket::attachEventBase(eventBase); AsyncSocket::attachEventBase(eventBase);
handshakeTimeout_.attachEventBase(eventBase); handshakeTimeout_.attachEventBase(eventBase);
} }
virtual void detachEventBase() { virtual void detachEventBase() override {
AsyncSocket::detachEventBase(); AsyncSocket::detachEventBase();
handshakeTimeout_.detachEventBase(); handshakeTimeout_.detachEventBase();
} }
...@@ -654,21 +654,22 @@ class AsyncSSLSocket : public virtual AsyncSocket { ...@@ -654,21 +654,22 @@ class AsyncSSLSocket : public virtual AsyncSocket {
// Inherit event notification methods from AsyncSocket except // Inherit event notification methods from AsyncSocket except
// the following. // the following.
void handleRead() noexcept; void handleRead() noexcept override;
void handleWrite() noexcept; void handleWrite() noexcept override;
void handleAccept() noexcept; void handleAccept() noexcept;
void handleConnect() noexcept; void handleConnect() noexcept override;
void invalidState(HandshakeCB* callback); void invalidState(HandshakeCB* callback);
bool willBlock(int ret, int *errorOut) noexcept; 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 // 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, 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 // This virtual wrapper around SSL_write exists solely for testing/mockability
virtual int sslWriteImpl(SSL *ssl, const void *buf, int n) { virtual int sslWriteImpl(SSL *ssl, const void *buf, int n) {
......
...@@ -186,7 +186,7 @@ class AsyncSocket : virtual public AsyncTransportWrapper { ...@@ -186,7 +186,7 @@ class AsyncSocket : virtual public AsyncTransportWrapper {
* This prevents callers from deleting a AsyncSocket while it is invoking a * This prevents callers from deleting a AsyncSocket while it is invoking a
* callback. * callback.
*/ */
virtual void destroy(); virtual void destroy() override;
/** /**
* Get the EventBase used by this socket. * Get the EventBase used by this socket.
......
...@@ -454,7 +454,7 @@ class EventBase : private boost::noncopyable, ...@@ -454,7 +454,7 @@ class EventBase : private boost::noncopyable,
* first handler fired within that cycle. * first handler fired within that cycle.
* *
*/ */
bool bumpHandlingTime(); bool bumpHandlingTime() override;
class SmoothLoopTime { class SmoothLoopTime {
public: public:
...@@ -519,15 +519,16 @@ class EventBase : private boost::noncopyable, ...@@ -519,15 +519,16 @@ class EventBase : private boost::noncopyable,
// TimeoutManager // TimeoutManager
void attachTimeoutManager(AsyncTimeout* obj, 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(); return isInEventBaseThread();
} }
......
...@@ -139,7 +139,7 @@ public: ...@@ -139,7 +139,7 @@ public:
explicit IntException(int i) explicit IntException(int i)
: i_(i) {} : i_(i) {}
virtual int getInt() const { return i_; } virtual int getInt() const override { return i_; }
virtual const char* what() const noexcept override { virtual const char* what() const noexcept override {
what_ = folly::to<std::string>("int == ", i_); what_ = folly::to<std::string>("int == ", i_);
return what_.c_str(); return what_.c_str();
......
...@@ -89,7 +89,7 @@ class AsyncSocketHandler ...@@ -89,7 +89,7 @@ class AsyncSocketHandler
return future; return future;
}; };
folly::Future<void> close(Context* ctx) { folly::Future<void> close(Context* ctx) override {
if (socket_) { if (socket_) {
detachReadCallback(); detachReadCallback();
socket_->closeNow(); socket_->closeNow();
......
...@@ -29,6 +29,11 @@ class MockChannelHandler : public ChannelHandler<Rin, Rout, Win, Wout> { ...@@ -29,6 +29,11 @@ class MockChannelHandler : public ChannelHandler<Rin, Rout, Win, Wout> {
MockChannelHandler() = default; MockChannelHandler() = default;
MockChannelHandler(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_METHOD2_T(read_, void(Context*, Rin&));
MOCK_METHOD1_T(readEOF, void(Context*)); MOCK_METHOD1_T(readEOF, void(Context*));
MOCK_METHOD2_T(readException, void(Context*, exception_wrapper)); MOCK_METHOD2_T(readException, void(Context*, exception_wrapper));
...@@ -41,7 +46,11 @@ class MockChannelHandler : public ChannelHandler<Rin, Rout, Win, Wout> { ...@@ -41,7 +46,11 @@ class MockChannelHandler : public ChannelHandler<Rin, Rout, Win, Wout> {
MOCK_METHOD1_T(detachPipeline, void(Context*)); MOCK_METHOD1_T(detachPipeline, void(Context*));
MOCK_METHOD1_T(detachTransport, 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); read_(ctx, msg);
} }
......
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