================ @@ -0,0 +1,219 @@ +//===- raw_ostream_proxy_test.cpp - Tests for raw ostream proxies ---------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "llvm/ADT/SmallString.h" +#include "llvm/Support/WithColor.h" +#include "llvm/Support/raw_ostream.h" +#include "llvm/Support/raw_ostream_proxy.h" +#include "gtest/gtest.h" + +using namespace llvm; + +namespace { + +/// Naive version of raw_svector_ostream that is buffered (by default) and +/// doesn't support pwrite. +class BufferedNoPwriteSmallVectorStream : public raw_ostream { +public: + // Choose a strange buffer size to ensure it doesn't collide with the default + // on \a raw_ostream. + constexpr static const size_t PreferredBufferSize = 63; + + size_t preferred_buffer_size() const override { return PreferredBufferSize; } + uint64_t current_pos() const override { return Vector.size(); } + void write_impl(const char *Ptr, size_t Size) override { + Vector.append(Ptr, Ptr + Size); + } + + bool is_displayed() const override { return IsDisplayed; } + + explicit BufferedNoPwriteSmallVectorStream(SmallVectorImpl<char> &Vector) + : Vector(Vector) {} + ~BufferedNoPwriteSmallVectorStream() override { flush(); } + + SmallVectorImpl<char> &Vector; + bool IsDisplayed = false; +}; + +constexpr const size_t BufferedNoPwriteSmallVectorStream::PreferredBufferSize; ---------------- zmodem wrote:
redundant `const` https://github.com/llvm/llvm-project/pull/68447 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits