summaryrefslogtreecommitdiffstats
path: root/examples/BrainF/BrainFDriver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/BrainF/BrainFDriver.cpp')
-rw-r--r--examples/BrainF/BrainFDriver.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/examples/BrainF/BrainFDriver.cpp b/examples/BrainF/BrainFDriver.cpp
index e2de6bc..99c8ff3 100644
--- a/examples/BrainF/BrainFDriver.cpp
+++ b/examples/BrainF/BrainFDriver.cpp
@@ -26,8 +26,8 @@
#include "BrainF.h"
#include "llvm/Bitcode/ReaderWriter.h"
+#include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/GenericValue.h"
-#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Verifier.h"
#include "llvm/Support/CommandLine.h"
@@ -107,9 +107,8 @@ int main(int argc, char **argv) {
OutputFilename = base+".bc";
}
if (OutputFilename != "-") {
- std::string ErrInfo;
- out = new raw_fd_ostream(OutputFilename.c_str(), ErrInfo,
- sys::fs::F_None);
+ std::error_code EC;
+ out = new raw_fd_ostream(OutputFilename, EC, sys::fs::F_None);
}
}
@@ -125,13 +124,13 @@ int main(int argc, char **argv) {
//Read the BrainF program
BrainF bf;
- Module *mod = bf.parse(in, 65536, cf, Context); //64 KiB
+ std::unique_ptr<Module> Mod(bf.parse(in, 65536, cf, Context)); // 64 KiB
if (in != &std::cin)
delete in;
- addMainFunction(mod);
+ addMainFunction(Mod.get());
//Verify generated code
- if (verifyModule(*mod)) {
+ if (verifyModule(*Mod)) {
errs() << "Error: module failed verification. This shouldn't happen.\n";
abort();
}
@@ -141,18 +140,18 @@ int main(int argc, char **argv) {
InitializeNativeTarget();
outs() << "------- Running JIT -------\n";
- ExecutionEngine *ee = EngineBuilder(mod).create();
+ Module &M = *Mod;
+ ExecutionEngine *ee = EngineBuilder(std::move(Mod)).create();
std::vector<GenericValue> args;
- Function *brainf_func = mod->getFunction("brainf");
+ Function *brainf_func = M.getFunction("brainf");
GenericValue gv = ee->runFunction(brainf_func, args);
} else {
- WriteBitcodeToFile(mod, *out);
+ WriteBitcodeToFile(Mod.get(), *out);
}
//Clean up
if (out != &outs())
delete out;
- delete mod;
llvm_shutdown();