summaryrefslogtreecommitdiff
path: root/unittests
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 /unittests
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 'unittests')
-rw-r--r--unittests/ExecutionEngine/JIT/JITTest.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/unittests/ExecutionEngine/JIT/JITTest.cpp b/unittests/ExecutionEngine/JIT/JITTest.cpp
index 817d207c2d..aa79bdc730 100644
--- a/unittests/ExecutionEngine/JIT/JITTest.cpp
+++ b/unittests/ExecutionEngine/JIT/JITTest.cpp
@@ -70,9 +70,9 @@ Function *makeReturnGlobal(std::string Name, GlobalVariable *G, Module *M) {
}
std::string DumpFunction(const Function *F) {
- std::string Result;
- raw_string_ostream(Result) << "" << *F;
- return Result;
+ string_ostream Result;
+ Result << "" << *F;
+ return Result.str();
}
class RecordingJITMemoryManager : public JITMemoryManager {
@@ -170,10 +170,9 @@ bool LoadAssemblyInto(Module *M, const char *assembly) {
SMDiagnostic Error;
bool success =
nullptr != ParseAssemblyString(assembly, M, Error, M->getContext());
- std::string errMsg;
- raw_string_ostream os(errMsg);
- Error.print("", os);
- EXPECT_TRUE(success) << os.str();
+ string_ostream errMsg;
+ Error.print("", errMsg);
+ EXPECT_TRUE(success) << errMsg.str();
return success;
}