From 255907042245b77779e3e38c5ce66901866cabe5 Mon Sep 17 00:00:00 2001 From: Alp Toker Date: Thu, 26 Jun 2014 00:00:48 +0000 Subject: 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 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 --- lib/MC/MCParser/AsmParser.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lib/MC/MCParser') diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp index fa5dfdc9fe..7bfbbf4932 100644 --- a/lib/MC/MCParser/AsmParser.cpp +++ b/lib/MC/MCParser/AsmParser.cpp @@ -4580,8 +4580,7 @@ bool AsmParser::parseMSInlineAsm( } // Build the IR assembly string. - std::string AsmStringIR; - raw_string_ostream OS(AsmStringIR); + string_ostream OS; const char *AsmStart = SrcMgr.getMemoryBuffer(0)->getBufferStart(); const char *AsmEnd = SrcMgr.getMemoryBuffer(0)->getBufferEnd(); array_pod_sort(AsmStrRewrites.begin(), AsmStrRewrites.end(), rewritesSort); @@ -4646,8 +4645,7 @@ bool AsmParser::parseMSInlineAsm( } case AOK_DotOperator: // Insert the dot if the user omitted it. - OS.flush(); - if (AsmStringIR.back() != '.') + if (OS.str().back() != '.') OS << '.'; OS << AR.Val; break; -- cgit v1.2.3