[PATCH] D115374: [NFC][clang] Return std::strings built from raw_string_ostreams more efficiently
Arthur O'Dwyer via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 8 13:16:51 PST 2021
Quuxplusone added inline comments.
================
Comment at: clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h:36
+ OS.flush();
+ return Str;
}
----------------
FWIW, it appears to me that in most (all?) of these cases, what's really wanted is not "a string //and// a stream" but rather "a stream that owns a string" (`std::ostringstream` or the LLVM-codebase equivalent thereof). Then the return can be `return std::move(OS).str();` — for `std::ostringstream`, this Does The Right Thing since C++20, and if LLVM had its own stringstream it could make it Do The Right Thing today.
https://en.cppreference.com/w/cpp/io/basic_ostringstream/str
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D115374/new/
https://reviews.llvm.org/D115374
More information about the cfe-commits
mailing list