llvm / llvm/llvm-project

Refactor raw_ostream to disallowed buffering API on ostreams that don't support buffering

Open
#175,832 0 comments 0 reactions 0 assignees View on GitHub
llvm:support
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

`raw_ostream` supports functions like `SetBuffered` and `flush` that make sense only if the ostream is buffered. Specific subclasses of raw_ostream, like raw_string_ostream, are intended to be unbuffered, but existing unit tests and code can call buffering related functions on these streams, leading either to bugs or unnecessary code (like calling flush on raw_string_ostream).

This issue asks for refactoring the raw_ostream class hierarchy so that buffering related functionality is removed from the base raw_ostream class and for unbuffered streams its a compile time error to call flush() or other API that's applicable only to buffered ostreams. As an example, we can have a `raw_ostream_buffered` subclass of `raw_ostream` and move all the buffering members there and use that as a base class for all buffered ostreams.

Contributor guide

Open the contributing guide

Research direction

Start by inspecting the raw_ostream class hierarchy, its buffering-related members, and the existing unit tests and callers mentioned in the issue. Map which subclasses support buffering, then verify that unbuffered streams reject buffering-only APIs at compile time and that affected tests and callers are updated.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.