summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Option
diff options
context:
space:
mode:
authorAlp Toker <alp@nuanti.com>2014-06-26 00:00:48 +0000
committerAlp Toker <alp@nuanti.com>2014-06-26 00:00:48 +0000
commit614717388cfccd6a6d34ed17a4680181e22cab22 (patch)
tree98ceaaca266d95b9e657783de3452ee20f891178 /llvm/lib/Option
parent49f09fd88afbf04a2c661c1917665b46f96729fa (diff)
downloadbcm5719-llvm-614717388cfccd6a6d34ed17a4680181e22cab22.tar.gz
bcm5719-llvm-614717388cfccd6a6d34ed17a4680181e22cab22.zip
Introduce a string_ostream string builder facilty
string_ostream is a safe and efficient string builder that combines opaque stack storage with a built-in ostream interface. small_string_ostream<bytes> additionally permits an explicit stack storage size other than the default 128 bytes to be provided. Beyond that, storage is transferred to the heap. This convenient class can be used in most places an std::string+raw_string_ostream pair or SmallString<>+raw_svector_ostream pair would previously have been used, in order to guarantee consistent access without byte truncation. The patch also converts much of LLVM to use the new facility. These changes include several probable bug fixes for truncated output, a programming error that's no longer possible with the new interface. llvm-svn: 211749
Diffstat (limited to 'llvm/lib/Option')
-rw-r--r--llvm/lib/Option/Arg.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/llvm/lib/Option/Arg.cpp b/llvm/lib/Option/Arg.cpp
index 4c8da58f536..30a69229737 100644
--- a/llvm/lib/Option/Arg.cpp
+++ b/llvm/lib/Option/Arg.cpp
@@ -62,8 +62,7 @@ void Arg::dump() const {
}
std::string Arg::getAsString(const ArgList &Args) const {
- SmallString<256> Res;
- llvm::raw_svector_ostream OS(Res);
+ small_string_ostream<256> OS;
ArgStringList ASL;
render(Args, ASL);
@@ -95,8 +94,7 @@ void Arg::render(const ArgList &Args, ArgStringList &Output) const {
break;
case Option::RenderCommaJoinedStyle: {
- SmallString<256> Res;
- llvm::raw_svector_ostream OS(Res);
+ small_string_ostream<256> OS;
OS << getSpelling();
for (unsigned i = 0, e = getNumValues(); i != e; ++i) {
if (i) OS << ',';
OpenPOWER on IntegriCloud