[PATCH] D115421: [Support] No longer require .flush()ing raw_string_ostream
Duncan P. N. Exon Smith via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 9 14:21:23 PST 2021
dexonsmith added inline comments.
================
Comment at: llvm/include/llvm/Support/raw_ostream.h:644-645
- /// Flushes the stream contents to the target string and returns the string's
- /// reference.
- std::string& str() {
- flush();
- return OS;
- }
+ /// Returns the string's reference.
+ std::string &str() { return OS; }
----------------
logan-5 wrote:
> dexonsmith wrote:
> > I wonder if this API should be deleted entirely? (not in this commit) -- in which case, could land just the change to the destructor here, then delete callers, then delete this.
> N.B. `raw_svector_ostream` has `str()` that returns `StringRef`, which appears to be useful in places. We could keep this for API parity, but change it to return `StringRef` to discourage using it to initialize `std::string`s.
Sure, fine by me if there are places where the `OS.str()` actually helps. I kind of suspect there aren't any though, and this was just to make flush+ref a one-liner.
`raw_svector_ostream::str()` is more useful since `SmallVectorImpl<char>` doesn't have an implicit conversion to `StringRef`, whereas `std::string` does.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D115421/new/
https://reviews.llvm.org/D115421
More information about the llvm-commits
mailing list