diff --git a/README.rst b/README.rst index ad697e6e..9038f883 100644 --- a/README.rst +++ b/README.rst @@ -11,7 +11,7 @@ :alt: fmt is continuously fuzzed at oss-fuzz :target: https://bugs.chromium.org/p/oss-fuzz/issues/list?\ colspec=ID%20Type%20Component%20Status%20Proj%20Reported%20Owner%20\ - Summary&q=proj%3Dlibfmt&can=1 + Summary&q=proj%3Dfmt&can=1 .. image:: https://img.shields.io/badge/stackoverflow-fmt-blue.svg :alt: Ask questions at StackOverflow with the tag fmt @@ -57,7 +57,7 @@ Features * Reliability: the library has an extensive set of `tests `_ and is `continuously fuzzed `_ + Component%20Status%20Proj%20Reported%20Owner%20Summary&q=proj%3Dfmt&can=1>`_ * Safety: the library is fully type safe, errors in format strings can be reported at compile time, automatic memory management prevents buffer overflow errors diff --git a/include/fmt/core.h b/include/fmt/core.h index 2e1ae4b6..ee98ea94 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -761,7 +761,7 @@ class fixed_buffer_traits { // A buffer that writes to an output iterator when flushed. template -class iterator_buffer : public Traits, public buffer { +class iterator_buffer final : public Traits, public buffer { private: OutputIt out_; enum { buffer_size = 256 }; @@ -787,7 +787,7 @@ class iterator_buffer : public Traits, public buffer { size_t count() const { return Traits::count() + this->size(); } }; -template class iterator_buffer : public buffer { +template class iterator_buffer final : public buffer { protected: void grow(size_t) final FMT_OVERRIDE {} @@ -801,7 +801,7 @@ template class iterator_buffer : public buffer { template class iterator_buffer, enable_if_t::value, - typename Container::value_type>> + typename Container::value_type>> final : public buffer { private: Container& container_; @@ -823,7 +823,7 @@ class iterator_buffer, }; // A buffer that counts the number of code units written discarding the output. -template class counting_buffer : public buffer { +template class counting_buffer final : public buffer { private: enum { buffer_size = 256 }; T data_[buffer_size]; diff --git a/include/fmt/format.h b/include/fmt/format.h index eb9e216a..6dbd12d6 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -651,7 +651,7 @@ enum { inline_buffer_size = 500 }; */ template > -class basic_memory_buffer : public detail::buffer { +class basic_memory_buffer final : public detail::buffer { private: T store_[SIZE]; diff --git a/include/fmt/os.h b/include/fmt/os.h index 66e66678..88151006 100644 --- a/include/fmt/os.h +++ b/include/fmt/os.h @@ -378,7 +378,7 @@ struct ostream_params { static constexpr detail::buffer_size buffer_size; // A fast output stream which is not thread-safe. -class ostream : private detail::buffer { +class ostream final : private detail::buffer { private: file file_; diff --git a/test/core-test.cc b/test/core-test.cc index 78d54bb1..9d88070d 100644 --- a/test/core-test.cc +++ b/test/core-test.cc @@ -78,7 +78,7 @@ TEST(BufferTest, Indestructible) { "buffer's destructor is protected"); } -template struct mock_buffer : buffer { +template struct mock_buffer final : buffer { MOCK_METHOD1(do_grow, size_t(size_t capacity)); void grow(size_t capacity) { this->set(this->data(), do_grow(capacity)); } @@ -368,7 +368,7 @@ TEST(ArgTest, PointerArg) { struct check_custom { test_result operator()( fmt::basic_format_arg::handle h) const { - struct test_buffer : fmt::detail::buffer { + struct test_buffer final : fmt::detail::buffer { char data[10]; test_buffer() : fmt::detail::buffer(data, 0, 10) {} void grow(size_t) {} diff --git a/test/format-test.cc b/test/format-test.cc index bf563e17..a3c925b0 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -293,12 +293,8 @@ TEST(MemoryBufferTest, MoveAssignment) { TEST(MemoryBufferTest, Grow) { typedef allocator_ref> Allocator; - typedef basic_memory_buffer Base; mock_allocator alloc; - struct TestMemoryBuffer : Base { - TestMemoryBuffer(Allocator alloc) : Base(alloc) {} - using Base::grow; - } buffer((Allocator(&alloc))); + basic_memory_buffer buffer((Allocator(&alloc))); buffer.resize(7); using fmt::detail::to_unsigned; for (int i = 0; i < 7; ++i) buffer[to_unsigned(i)] = i * i; @@ -306,7 +302,7 @@ TEST(MemoryBufferTest, Grow) { int mem[20]; mem[7] = 0xdead; EXPECT_CALL(alloc, allocate(20)).WillOnce(Return(mem)); - buffer.grow(20); + buffer.try_reserve(20); EXPECT_EQ(20u, buffer.capacity()); // Check if size elements have been copied for (int i = 0; i < 7; ++i) EXPECT_EQ(i * i, buffer[to_unsigned(i)]); diff --git a/test/ostream-test.cc b/test/ostream-test.cc index 407b05a1..ebf14210 100644 --- a/test/ostream-test.cc +++ b/test/ostream-test.cc @@ -150,7 +150,7 @@ TEST(OStreamTest, WriteToOStreamMaxSize) { std::streamsize max_streamsize = fmt::detail::max_value(); if (max_size <= fmt::detail::to_unsigned(max_streamsize)) return; - struct test_buffer : fmt::detail::buffer { + struct test_buffer final : fmt::detail::buffer { explicit test_buffer(size_t size) : fmt::detail::buffer(nullptr, size, size) {} void grow(size_t) {}