From 8fe79ff17abec2d7d254cdfbe2a4c13f954493ad Mon Sep 17 00:00:00 2001 From: Yedidya Feldblum Date: Mon, 14 Sep 2015 12:57:14 -0700 Subject: [PATCH] CodeMod: Drop FOLLY_OVERRIDE and FOLLY_FINAL Summary: [Folly] CodeMod: Drop `FOLLY_OVERRIDE` and `FOLLY_FINAL`. These were to support GCC 4.6 and earlier, and MSVC 2008 and earlier. Reviewed By: @philippv Differential Revision: D2438309 --- folly/Portability.h | 15 ----------- folly/Subprocess.h | 4 +-- folly/io/Compression.cpp | 48 +++++++++++++++++----------------- folly/test/PortabilityTest.cpp | 2 +- 4 files changed, 27 insertions(+), 42 deletions(-) diff --git a/folly/Portability.h b/folly/Portability.h index 17d07e20..7ccedfac 100644 --- a/folly/Portability.h +++ b/folly/Portability.h @@ -172,21 +172,6 @@ namespace std { typedef ::max_align_t max_align_t; } #endif -/* Define macro wrappers for C++11's "final" and "override" keywords, which - * are supported in gcc 4.7 but not gcc 4.6. */ -#if !defined(FOLLY_FINAL) && !defined(FOLLY_OVERRIDE) -# if defined(__clang__) || __GNUC_PREREQ(4, 7) -# define FOLLY_FINAL final -# define FOLLY_OVERRIDE override -# elif defined(_MSC_VER) && _MSC_VER >= 1600 -# define FOLLY_FINAL final -# define FOLLY_OVERRIDE override -# else -# define FOLLY_FINAL /**/ -# define FOLLY_OVERRIDE /**/ -# endif -#endif - /* Platform specific TLS support * gcc implements __thread * msvc implements __declspec(thread) diff --git a/folly/Subprocess.h b/folly/Subprocess.h index 4f970082..cdd8e38d 100644 --- a/folly/Subprocess.h +++ b/folly/Subprocess.h @@ -215,7 +215,7 @@ class CalledProcessError : public SubprocessError { public: explicit CalledProcessError(ProcessReturnCode rc); ~CalledProcessError() throw() = default; - const char* what() const throw() FOLLY_OVERRIDE { return what_.c_str(); } + const char* what() const throw() override { return what_.c_str(); } ProcessReturnCode returnCode() const { return returnCode_; } private: ProcessReturnCode returnCode_; @@ -229,7 +229,7 @@ class SubprocessSpawnError : public SubprocessError { public: SubprocessSpawnError(const char* executable, int errCode, int errnoValue); ~SubprocessSpawnError() throw() = default; - const char* what() const throw() FOLLY_OVERRIDE { return what_.c_str(); } + const char* what() const throw() override { return what_.c_str(); } int errnoValue() const { return errnoValue_; } private: diff --git a/folly/io/Compression.cpp b/folly/io/Compression.cpp index 8c8012da..97c62f07 100644 --- a/folly/io/Compression.cpp +++ b/folly/io/Compression.cpp @@ -101,16 +101,16 @@ namespace { /** * No compression */ -class NoCompressionCodec FOLLY_FINAL : public Codec { +class NoCompressionCodec final : public Codec { public: static std::unique_ptr create(int level, CodecType type); explicit NoCompressionCodec(int level, CodecType type); private: - std::unique_ptr doCompress(const IOBuf* data) FOLLY_OVERRIDE; + std::unique_ptr doCompress(const IOBuf* data) override; std::unique_ptr doUncompress( const IOBuf* data, - uint64_t uncompressedLength) FOLLY_OVERRIDE; + uint64_t uncompressedLength) override; }; std::unique_ptr NoCompressionCodec::create(int level, CodecType type) { @@ -182,21 +182,21 @@ inline uint64_t decodeVarintFromCursor(folly::io::Cursor& cursor) { /** * LZ4 compression */ -class LZ4Codec FOLLY_FINAL : public Codec { +class LZ4Codec final : public Codec { public: static std::unique_ptr create(int level, CodecType type); explicit LZ4Codec(int level, CodecType type); private: - bool doNeedsUncompressedLength() const FOLLY_OVERRIDE; - uint64_t doMaxUncompressedLength() const FOLLY_OVERRIDE; + bool doNeedsUncompressedLength() const override; + uint64_t doMaxUncompressedLength() const override; bool encodeSize() const { return type() == CodecType::LZ4_VARINT_SIZE; } - std::unique_ptr doCompress(const IOBuf* data) FOLLY_OVERRIDE; + std::unique_ptr doCompress(const IOBuf* data) override; std::unique_ptr doUncompress( const IOBuf* data, - uint64_t uncompressedLength) FOLLY_OVERRIDE; + uint64_t uncompressedLength) override; bool highCompression_; }; @@ -325,12 +325,12 @@ std::unique_ptr LZ4Codec::doUncompress( /** * Implementation of snappy::Source that reads from a IOBuf chain. */ -class IOBufSnappySource FOLLY_FINAL : public snappy::Source { +class IOBufSnappySource final : public snappy::Source { public: explicit IOBufSnappySource(const IOBuf* data); - size_t Available() const FOLLY_OVERRIDE; - const char* Peek(size_t* len) FOLLY_OVERRIDE; - void Skip(size_t n) FOLLY_OVERRIDE; + size_t Available() const override; + const char* Peek(size_t* len) override; + void Skip(size_t n) override; private: size_t available_; io::Cursor cursor_; @@ -357,17 +357,17 @@ void IOBufSnappySource::Skip(size_t n) { available_ -= n; } -class SnappyCodec FOLLY_FINAL : public Codec { +class SnappyCodec final : public Codec { public: static std::unique_ptr create(int level, CodecType type); explicit SnappyCodec(int level, CodecType type); private: - uint64_t doMaxUncompressedLength() const FOLLY_OVERRIDE; - std::unique_ptr doCompress(const IOBuf* data) FOLLY_OVERRIDE; + uint64_t doMaxUncompressedLength() const override; + std::unique_ptr doCompress(const IOBuf* data) override; std::unique_ptr doUncompress( const IOBuf* data, - uint64_t uncompressedLength) FOLLY_OVERRIDE; + uint64_t uncompressedLength) override; }; std::unique_ptr SnappyCodec::create(int level, CodecType type) { @@ -443,16 +443,16 @@ std::unique_ptr SnappyCodec::doUncompress(const IOBuf* data, /** * Zlib codec */ -class ZlibCodec FOLLY_FINAL : public Codec { +class ZlibCodec final : public Codec { public: static std::unique_ptr create(int level, CodecType type); explicit ZlibCodec(int level, CodecType type); private: - std::unique_ptr doCompress(const IOBuf* data) FOLLY_OVERRIDE; + std::unique_ptr doCompress(const IOBuf* data) override; std::unique_ptr doUncompress( const IOBuf* data, - uint64_t uncompressedLength) FOLLY_OVERRIDE; + uint64_t uncompressedLength) override; std::unique_ptr addOutputBuffer(z_stream* stream, uint32_t length); bool doInflate(z_stream* stream, IOBuf* head, uint32_t bufferLength); @@ -684,21 +684,21 @@ std::unique_ptr ZlibCodec::doUncompress(const IOBuf* data, /** * LZMA2 compression */ -class LZMA2Codec FOLLY_FINAL : public Codec { +class LZMA2Codec final : public Codec { public: static std::unique_ptr create(int level, CodecType type); explicit LZMA2Codec(int level, CodecType type); private: - bool doNeedsUncompressedLength() const FOLLY_OVERRIDE; - uint64_t doMaxUncompressedLength() const FOLLY_OVERRIDE; + bool doNeedsUncompressedLength() const override; + uint64_t doMaxUncompressedLength() const override; bool encodeSize() const { return type() == CodecType::LZMA2_VARINT_SIZE; } - std::unique_ptr doCompress(const IOBuf* data) FOLLY_OVERRIDE; + std::unique_ptr doCompress(const IOBuf* data) override; std::unique_ptr doUncompress( const IOBuf* data, - uint64_t uncompressedLength) FOLLY_OVERRIDE; + uint64_t uncompressedLength) override; std::unique_ptr addOutputBuffer(lzma_stream* stream, size_t length); bool doInflate(lzma_stream* stream, IOBuf* head, size_t bufferLength); diff --git a/folly/test/PortabilityTest.cpp b/folly/test/PortabilityTest.cpp index 62b25553..923c2391 100644 --- a/folly/test/PortabilityTest.cpp +++ b/folly/test/PortabilityTest.cpp @@ -28,7 +28,7 @@ class Base { class Derived : public Base { public: - int foo() const FOLLY_FINAL { return 2; } + int foo() const final { return 2; } }; // A compiler that supports final will likely inline the call to p->foo() -- 2.34.1