diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-09-01 06:53:41 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-09-01 06:53:41 +0000 |
commit | 400aea6b9d4d0a33f4c6cae4cada7e54029fccc4 (patch) | |
tree | 274e25a9d0d9353b3a41a60b0636edbd73d22473 /lib/Module/KModule.cpp | |
parent | 0f0b921714a32b51a1bbda1848a356bb4553f3d3 (diff) | |
download | klee-400aea6b9d4d0a33f4c6cae4cada7e54029fccc4.tar.gz |
Update for LLVM ostream changes.
- Includes patch by Michael Stone! git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@80665 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Module/KModule.cpp')
-rw-r--r-- | lib/Module/KModule.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/lib/Module/KModule.cpp b/lib/Module/KModule.cpp index 37e869c8..55eb4b8a 100644 --- a/lib/Module/KModule.cpp +++ b/lib/Module/KModule.cpp @@ -27,6 +27,7 @@ #include "llvm/ValueSymbolTable.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/raw_os_ostream.h" #include "llvm/System/Path.h" #include "llvm/Target/TargetData.h" #include "llvm/Transforms/Scalar.h" @@ -326,42 +327,47 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts, std::ostream *os = ih->openOutputFile("assembly.ll"); assert(os && os->good() && "unable to open source output"); + llvm::raw_os_ostream *ros = new llvm::raw_os_ostream(*os); + // We have an option for this in case the user wants a .ll they // can compile. if (NoTruncateSourceLines) { - *os << *module; + *ros << *module; } else { bool truncated = false; - std::stringstream buffer; - buffer << *module; - std::string string = buffer.str(); + std::string string; + llvm::raw_string_ostream rss(string); + rss << *module; + rss.flush(); const char *position = string.c_str(); for (;;) { const char *end = index(position, '\n'); if (!end) { - *os << position; + *ros << position; break; } else { unsigned count = (end - position) + 1; if (count<255) { - os->write(position, count); + ros->write(position, count); } else { - os->write(position, 254); - *os << "\n"; + ros->write(position, 254); + *ros << "\n"; truncated = true; } position = end+1; } } } - + delete ros; delete os; } if (OutputModule) { std::ostream *f = ih->openOutputFile("final.bc"); - WriteBitcodeToFile(module, *f); + llvm::raw_os_ostream* rfs = new llvm::raw_os_ostream(*f); + WriteBitcodeToFile(module, *rfs); + delete rfs; delete f; } |