folly: avoid new warnings from -Winconsistent-missing-override
authorJim Meyering <meyering@fb.com>
Fri, 13 Feb 2015 18:36:27 +0000 (10:36 -0800)
committerAlecs King <int@fb.com>
Tue, 3 Mar 2015 03:19:57 +0000 (19:19 -0800)
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

folly/futures/test/ViaTest.cpp
folly/io/async/AsyncSSLSocket.h
folly/io/async/AsyncSocket.h
folly/io/async/EventBase.h
folly/test/ExceptionWrapperTest.cpp
folly/wangle/channel/AsyncSocketHandler.h
folly/wangle/channel/test/MockChannelHandler.h

index 4a78ce7dbc0e83367d817aa20f2096ce0a541c69..d203c18c211eb630f97d359877a6ebb24776b54f 100644 (file)
@@ -27,7 +27,7 @@ using namespace folly;
 struct ManualWaiter : public DrivableExecutor {
   explicit ManualWaiter(std::shared_ptr<ManualExecutor> ex) : ex(ex) {}
 
-  void add(Func f) {
+  void add(Func f) override {
     ex->add(f);
   }
 
index 8f3c8bd086870ea83901bc8fa378f1c31ecb031d..ec8f700efddbaa288461571fa593482aa463a983 100644 (file)
@@ -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) {
index 10614abf04cbab8d1a25cb83b02ea7c3afdd7eec..b8b23016ce7fa6724632d75567302ac9bfad36dd 100644 (file)
@@ -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.
index 390ee243c82f8d2c1698e5d36c3651e25462bc3a..a4051dfea5a74d6bfa4de945a3b3ee87dab58cb5 100644 (file)
@@ -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();
   }
 
index bfeac2bcdb6666d62fa4ef9f0be09eee2498b577..96b09334fbcbe0a26cfadb4b846b0ed2b08e778f 100644 (file)
@@ -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<std::string>("int == ", i_);
     return what_.c_str();
index 46fb03b8a9bb0cbeb9b2a264b32704b5e2e1ea28..e4bb98eeceff0ecc00b6e8e9b808f4c003774583 100644 (file)
@@ -89,7 +89,7 @@ class AsyncSocketHandler
     return future;
   };
 
-  folly::Future<void> close(Context* ctx) {
+  folly::Future<void> close(Context* ctx) override {
     if (socket_) {
       detachReadCallback();
       socket_->closeNow();
index 0c666d9415b7c4fec740924002cd2b2ea762844c..930867044613ce045ddeede005eb99d0531bf011 100644 (file)
@@ -29,6 +29,11 @@ class MockChannelHandler : public ChannelHandler<Rin, Rout, Win, Wout> {
   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<Rin, Rout, Win, Wout> {
   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);
   }