r215979 - Go back to having a takeModule instead of a getModule.

Rafael Espindola rafael.espindola at gmail.com
Tue Aug 19 07:32:16 PDT 2014


Author: rafael
Date: Tue Aug 19 09:32:16 2014
New Revision: 215979

URL: http://llvm.org/viewvc/llvm-project?rev=215979&view=rev
Log:
Go back to having a takeModule instead of a getModule.

Returning a std::unique_ptr is more constrained. Thanks to David Blaikie for the
suggestion.

Modified:
    cfe/trunk/examples/clang-interpreter/main.cpp
    cfe/trunk/include/clang/CodeGen/CodeGenAction.h

Modified: cfe/trunk/examples/clang-interpreter/main.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/clang-interpreter/main.cpp?rev=215979&r1=215978&r2=215979&view=diff
==============================================================================
--- cfe/trunk/examples/clang-interpreter/main.cpp (original)
+++ cfe/trunk/examples/clang-interpreter/main.cpp Tue Aug 19 09:32:16 2014
@@ -165,7 +165,7 @@ int main(int argc, const char **argv, ch
     return 1;
 
   int Res = 255;
-  if (std::unique_ptr<llvm::Module> &Module = Act->getModule())
+  if (std::unique_ptr<llvm::Module> Module = Act->takeModule())
     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=215979&r1=215978&r2=215979&view=diff
==============================================================================
--- cfe/trunk/include/clang/CodeGen/CodeGenAction.h (original)
+++ cfe/trunk/include/clang/CodeGen/CodeGenAction.h Tue Aug 19 09:32:16 2014
@@ -54,7 +54,7 @@ public:
 
   /// 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; }
+  std::unique_ptr<llvm::Module> takeModule() { return std::move(TheModule); }
 
   /// Take the LLVM context used by this action.
   llvm::LLVMContext *takeLLVMContext();





More information about the cfe-commits mailing list