Refactor raw_ostream to disallowed buffering API on ostreams that don't support buffering
- 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
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