Skip to content

Commit 2b29125

Browse files
committed
Approved by Chris:
$ svn merge -c 113123 https://llvm.org/svn/llvm-project/llvm/trunk --- Merging r113123 into '.': U examples/Fibonacci/fibonacci.cpp fit in 80 columns and don't crash on exit, fixes PR8080 llvm-svn: 113150
1 parent ee8092b commit 2b29125

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

llvm/examples/Fibonacci/fibonacci.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,22 @@ int main(int argc, char **argv) {
9696
LLVMContext Context;
9797

9898
// Create some module to put our function into it.
99-
Module *M = new Module("test", Context);
99+
OwningPtr<Module> M(new Module("test", Context));
100100

101101
// We are about to create the "fib" function:
102-
Function *FibF = CreateFibFunction(M, Context);
102+
Function *FibF = CreateFibFunction(M.get(), Context);
103103

104104
// Now we going to create JIT
105105
std::string errStr;
106-
ExecutionEngine *EE = EngineBuilder(M).setErrorStr(&errStr).setEngineKind(EngineKind::JIT).create();
106+
ExecutionEngine *EE =
107+
EngineBuilder(M.get())
108+
.setErrorStr(&errStr)
109+
.setEngineKind(EngineKind::JIT)
110+
.create();
107111

108112
if (!EE) {
109-
errs() << argv[0] << ": Failed to construct ExecutionEngine: " << errStr << "\n";
113+
errs() << argv[0] << ": Failed to construct ExecutionEngine: " << errStr
114+
<< "\n";
110115
return 1;
111116
}
112117

@@ -127,5 +132,6 @@ int main(int argc, char **argv) {
127132

128133
// import result of execution
129134
outs() << "Result: " << GV.IntVal << "\n";
135+
130136
return 0;
131137
}

0 commit comments

Comments
 (0)