summaryrefslogtreecommitdiff
path: root/lib/TableGen
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
commit255907042245b77779e3e38c5ce66901866cabe5 (patch)
tree92db65aa99c37ab5f68cd6adaae1d8cf6d629b8f /lib/TableGen
parentce6e7c7a59e8595ea3f30d87cbad4af278cb5ef3 (diff)
downloadllvm-255907042245b77779e3e38c5ce66901866cabe5.tar.gz
llvm-255907042245b77779e3e38c5ce66901866cabe5.tar.bz2
llvm-255907042245b77779e3e38c5ce66901866cabe5.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211749 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/TableGen')
-rw-r--r--lib/TableGen/SetTheory.cpp11
-rw-r--r--lib/TableGen/TGParser.cpp3
2 files changed, 6 insertions, 8 deletions
diff --git a/lib/TableGen/SetTheory.cpp b/lib/TableGen/SetTheory.cpp
index c99c2bab45..594d4d9a94 100644
--- a/lib/TableGen/SetTheory.cpp
+++ b/lib/TableGen/SetTheory.cpp
@@ -209,13 +209,12 @@ struct SequenceOp : public SetTheory::Operator {
break;
else if (Step < 0 && From < To)
break;
- std::string Name;
- raw_string_ostream OS(Name);
- OS << format(Format.c_str(), unsigned(From));
- Record *Rec = Records.getDef(OS.str());
+ string_ostream Name;
+ Name << format(Format.c_str(), unsigned(From));
+ Record *Rec = Records.getDef(Name.str());
if (!Rec)
- PrintFatalError(Loc, "No def named '" + Name + "': " +
- Expr->getAsString());
+ PrintFatalError(Loc, "No def named '" + Name.str() + "': " +
+ Expr->getAsString());
// Try to reevaluate Rec in case it is a set.
if (const RecVec *Result = ST.expand(Rec))
Elts.insert(Result->begin(), Result->end());
diff --git a/lib/TableGen/TGParser.cpp b/lib/TableGen/TGParser.cpp
index 0550692ebc..76ef696c68 100644
--- a/lib/TableGen/TGParser.cpp
+++ b/lib/TableGen/TGParser.cpp
@@ -1307,8 +1307,7 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType,
if (ItemType) {
ListRecTy *ListType = dyn_cast<ListRecTy>(ItemType);
if (!ListType) {
- std::string s;
- raw_string_ostream ss(s);
+ string_ostream ss;
ss << "Type mismatch for list, expected list type, got "
<< ItemType->getAsString();
TokError(ss.str());