r215968 - Update for llvm api change.
Rafael Espindola
rafael.espindola at gmail.com
Mon Aug 18 21:04:30 PDT 2014
Author: rafael
Date: Mon Aug 18 23:04:30 2014
New Revision: 215968
URL: http://llvm.org/viewvc/llvm-project?rev=215968&view=rev
Log:
Update for llvm api change.
Modified:
cfe/trunk/examples/clang-interpreter/main.cpp
cfe/trunk/include/clang/CodeGen/CodeGenAction.h
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
Modified: cfe/trunk/examples/clang-interpreter/main.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/clang-interpreter/main.cpp?rev=215968&r1=215967&r2=215968&view=diff
==============================================================================
--- cfe/trunk/examples/clang-interpreter/main.cpp (original)
+++ cfe/trunk/examples/clang-interpreter/main.cpp Mon Aug 18 23:04:30 2014
@@ -42,27 +42,29 @@ std::string GetExecutablePath(const char
return llvm::sys::fs::getMainExecutable(Argv0, MainAddr);
}
-static llvm::ExecutionEngine *createExecutionEngine(llvm::Module *M,
- std::string *ErrorStr) {
- llvm::EngineBuilder EB = llvm::EngineBuilder(M)
- .setUseMCJIT(true)
- .setEngineKind(llvm::EngineKind::Either)
- .setErrorStr(ErrorStr);
- return EB.create();
+static llvm::ExecutionEngine *
+createExecutionEngine(std::unique_ptr<llvm::Module> M, std::string *ErrorStr) {
+ return llvm::EngineBuilder(std::move(M))
+ .setUseMCJIT(true)
+ .setEngineKind(llvm::EngineKind::Either)
+ .setErrorStr(ErrorStr)
+ .create();
}
-static int Execute(llvm::Module *Mod, char * const *envp) {
+static int Execute(std::unique_ptr<llvm::Module> Mod, char *const *envp) {
llvm::InitializeNativeTarget();
llvm::InitializeNativeTargetAsmPrinter();
+ llvm::Module &M = *Mod;
std::string Error;
- std::unique_ptr<llvm::ExecutionEngine> EE(createExecutionEngine(Mod, &Error));
+ std::unique_ptr<llvm::ExecutionEngine> EE(
+ createExecutionEngine(std::move(Mod), &Error));
if (!EE) {
llvm::errs() << "unable to make execution engine: " << Error << "\n";
return 255;
}
- llvm::Function *EntryFn = Mod->getFunction("main");
+ llvm::Function *EntryFn = M.getFunction("main");
if (!EntryFn) {
llvm::errs() << "'main' function not found in module.\n";
return 255;
@@ -70,7 +72,7 @@ static int Execute(llvm::Module *Mod, ch
// FIXME: Support passing arguments.
std::vector<std::string> Args;
- Args.push_back(Mod->getModuleIdentifier());
+ Args.push_back(M.getModuleIdentifier());
EE->finalizeObject();
return EE->runFunctionAsMain(EntryFn, Args, envp);
@@ -163,8 +165,8 @@ int main(int argc, const char **argv, ch
return 1;
int Res = 255;
- if (llvm::Module *Module = Act->takeModule())
- Res = Execute(Module, envp);
+ if (std::unique_ptr<llvm::Module> &Module = Act->getModule())
+ Res = Execute(std::move(Module), envp);
// Shutdown.
Modified: cfe/trunk/include/clang/CodeGen/CodeGenAction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/CodeGenAction.h?rev=215968&r1=215967&r2=215968&view=diff
==============================================================================
--- cfe/trunk/include/clang/CodeGen/CodeGenAction.h (original)
+++ cfe/trunk/include/clang/CodeGen/CodeGenAction.h Mon Aug 18 23:04:30 2014
@@ -52,9 +52,9 @@ public:
/// the action will load it from the specified file.
void setLinkModule(llvm::Module *Mod) { LinkModule = Mod; }
- /// takeModule - Take the generated LLVM module, for use after the action has
- /// been run. The result may be null on failure.
- llvm::Module *takeModule();
+ /// Take the generated LLVM module, for use after the action has been run.
+ /// The result may be null on failure.
+ std::unique_ptr<llvm::Module> &getModule() { return TheModule; }
/// Take the LLVM context used by this action.
llvm::LLVMContext *takeLLVMContext();
Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=215968&r1=215967&r2=215968&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Mon Aug 18 23:04:30 2014
@@ -579,8 +579,6 @@ void CodeGenAction::EndSourceFileAction(
TheModule.reset(BEConsumer->takeModule());
}
-llvm::Module *CodeGenAction::takeModule() { return TheModule.release(); }
-
llvm::LLVMContext *CodeGenAction::takeLLVMContext() {
OwnsVMContext = false;
return VMContext;
More information about the cfe-commits
mailing list