aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/Module
diff options
context:
space:
mode:
authorMartinNowack <martin.nowack@gmail.com>2014-05-30 00:09:00 +0200
committerMartinNowack <martin.nowack@gmail.com>2014-05-30 00:09:00 +0200
commit15470d2661900bae90ac457dd60694a4f4f7ec3c (patch)
treea3b45da7700f765408b1236eeefd4d1ec01e22bb /lib/Module
parentc2dec441f3f89916962175f0307b5c33473fa616 (diff)
parenteaac527a2821c41aa88c8767fd0305f9d610fb23 (diff)
downloadklee-15470d2661900bae90ac457dd60694a4f4f7ec3c.tar.gz
Merge pull request #117 from MartinNowack/llvm_raw_ostream
Refactor std::ostreams to llvm::raw_ostream and minor cleanups
Diffstat (limited to 'lib/Module')
-rw-r--r--lib/Module/Checks.cpp1
-rw-r--r--lib/Module/KModule.cpp24
-rw-r--r--lib/Module/ModuleUtil.cpp2
-rw-r--r--lib/Module/Optimize.cpp3
4 files changed, 10 insertions, 20 deletions
diff --git a/lib/Module/Checks.cpp b/lib/Module/Checks.cpp
index 80b6b245..e1076d43 100644
--- a/lib/Module/Checks.cpp
+++ b/lib/Module/Checks.cpp
@@ -46,7 +46,6 @@
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Support/CallSite.h"
-#include <iostream>
using namespace llvm;
using namespace klee;
diff --git a/lib/Module/KModule.cpp b/lib/Module/KModule.cpp
index e06e722a..697b6ea9 100644
--- a/lib/Module/KModule.cpp
+++ b/lib/Module/KModule.cpp
@@ -430,15 +430,13 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts,
// around a kcachegrind parsing bug (it puts them on new lines), so
// that source browsing works.
if (OutputSource) {
- 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);
+ llvm::raw_fd_ostream *os = ih->openOutputFile("assembly.ll");
+ assert(os && !os->has_error() && "unable to open source output");
// We have an option for this in case the user wants a .ll they
// can compile.
if (NoTruncateSourceLines) {
- *ros << *module;
+ *os << *module;
} else {
std::string string;
llvm::raw_string_ostream rss(string);
@@ -449,30 +447,26 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts,
for (;;) {
const char *end = index(position, '\n');
if (!end) {
- *ros << position;
+ *os << position;
break;
} else {
unsigned count = (end - position) + 1;
if (count<255) {
- ros->write(position, count);
+ os->write(position, count);
} else {
- ros->write(position, 254);
- *ros << "\n";
+ os->write(position, 254);
+ *os << "\n";
}
position = end+1;
}
}
}
- delete ros;
-
delete os;
}
if (OutputModule) {
- std::ostream *f = ih->openOutputFile("final.bc");
- llvm::raw_os_ostream* rfs = new llvm::raw_os_ostream(*f);
- WriteBitcodeToFile(module, *rfs);
- delete rfs;
+ llvm::raw_fd_ostream *f = ih->openOutputFile("final.bc");
+ WriteBitcodeToFile(module, *f);
delete f;
}
diff --git a/lib/Module/ModuleUtil.cpp b/lib/Module/ModuleUtil.cpp
index 4f65d0e7..d00cf574 100644
--- a/lib/Module/ModuleUtil.cpp
+++ b/lib/Module/ModuleUtil.cpp
@@ -28,7 +28,6 @@
#include "llvm/Object/ObjectFile.h"
#include "llvm/Object/Error.h"
#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/raw_os_ostream.h"
#include "llvm/IR/ValueSymbolTable.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/DataStream.h"
@@ -51,7 +50,6 @@
#include <map>
#include <set>
-#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
diff --git a/lib/Module/Optimize.cpp b/lib/Module/Optimize.cpp
index 9c200bc8..ed1e0e34 100644
--- a/lib/Module/Optimize.cpp
+++ b/lib/Module/Optimize.cpp
@@ -40,7 +40,6 @@
#include "llvm/Transforms/Scalar.h"
#include "llvm/Support/PassNameParser.h"
#include "llvm/Support/PluginLoader.h"
-#include <iostream>
using namespace llvm;
#if 0
@@ -272,7 +271,7 @@ void Optimize(Module* M) {
if (Opt->getNormalCtor())
addPass(Passes, Opt->getNormalCtor()());
else
- std::cerr << "llvm-ld: cannot create pass: " << Opt->getPassName()
+ llvm::errs() << "llvm-ld: cannot create pass: " << Opt->getPassName()
<< "\n";
}
#endif