[Lldb-commits] [lldb] r166598 - /lldb/trunk/source/Expression/ClangExpressionParser.cpp

Greg Clayton gclayton at apple.com
Wed Oct 24 10:37:53 PDT 2012


Author: gclayton
Date: Wed Oct 24 12:37:53 2012
New Revision: 166598

URL: http://llvm.org/viewvc/llvm-project?rev=166598&view=rev
Log:
Cleanup some variable names to indicate auto pointers and also manager the llvm::Module memory more correctly.


Modified:
    lldb/trunk/source/Expression/ClangExpressionParser.cpp

Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=166598&r1=166597&r2=166598&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Wed Oct 24 12:37:53 2012
@@ -463,13 +463,13 @@
 	func_end = LLDB_INVALID_ADDRESS;
     lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
-    std::auto_ptr<llvm::ExecutionEngine> execution_engine;
+    std::auto_ptr<llvm::ExecutionEngine> execution_engine_ap;
     
     Error err;
     
-    llvm::Module *module = m_code_generator->ReleaseModule();
+    std::auto_ptr<llvm::Module> module_ap (m_code_generator->ReleaseModule());
 
-    if (!module)
+    if (!module_ap.get())
     {
         err.SetErrorToGenericError();
         err.SetErrorString("IR doesn't contain a module");
@@ -480,7 +480,7 @@
     
     std::string function_name;
     
-    if (!FindFunctionInModule(function_name, module, m_expr.FunctionName()))
+    if (!FindFunctionInModule(function_name, module_ap.get(), m_expr.FunctionName()))
     {
         err.SetErrorToGenericError();
         err.SetErrorStringWithFormat("Couldn't find %s() in the module", m_expr.FunctionName());
@@ -509,7 +509,7 @@
                                   error_stream,
                                   function_name.c_str());
         
-        bool ir_can_run = ir_for_target.runOnModule(*module);
+        bool ir_can_run = ir_for_target.runOnModule(*module_ap);
         
         Error &interpreter_error(ir_for_target.getInterpreterError());
         
@@ -570,7 +570,7 @@
             
             IRDynamicChecks ir_dynamic_checks(*process->GetDynamicCheckers(), function_name.c_str());
         
-            if (!ir_dynamic_checks.runOnModule(*module))
+            if (!ir_dynamic_checks.runOnModule(*module_ap))
             {
                 err.SetErrorToGenericError();
                 err.SetErrorString("Couldn't add dynamic checks to the expression");
@@ -590,14 +590,15 @@
         std::string s;
         raw_string_ostream oss(s);
         
-        module->print(oss, NULL);
+        module_ap->print(oss, NULL);
         
         oss.flush();
         
         log->Printf ("Module being sent to JIT: \n%s", s.c_str());
     }
-    
-    EngineBuilder builder(module);
+    llvm::Triple triple(module_ap->getTargetTriple());
+    llvm::Function *function = module_ap->getFunction (function_name.c_str());
+    EngineBuilder builder(module_ap.release());
     builder.setEngineKind(EngineKind::JIT)
         .setErrorStr(&error_string)
         .setRelocationModel(llvm::Reloc::PIC_)
@@ -607,7 +608,6 @@
         .setCodeModel(CodeModel::Small)
         .setUseMCJIT(true);
     
-    llvm::Triple triple(module->getTargetTriple());
     StringRef mArch;
     StringRef mCPU;
     SmallVector<std::string, 0> mAttrs;
@@ -617,22 +617,21 @@
                                                          mCPU,
                                                          mAttrs);
     
-    execution_engine.reset(builder.create(target_machine));
+    execution_engine_ap.reset(builder.create(target_machine));
         
-    if (!execution_engine.get())
+    if (!execution_engine_ap.get())
     {
         err.SetErrorToGenericError();
         err.SetErrorStringWithFormat("Couldn't JIT the function: %s", error_string.c_str());
         return err;
     }
     
-    execution_engine->DisableLazyCompilation();
+    execution_engine_ap->DisableLazyCompilation();
     
-    llvm::Function *function = module->getFunction (function_name.c_str());
     
     // We don't actually need the function pointer here, this just forces it to get resolved.
     
-    void *fun_ptr = execution_engine->getPointerToFunction(function);
+    void *fun_ptr = execution_engine_ap->getPointerToFunction(function);
         
     // Errors usually cause failures in the JIT, but if we're lucky we get here.
     
@@ -662,7 +661,7 @@
     }
         
     jit_memory_manager->CommitAllocations(*process);
-    jit_memory_manager->ReportAllocations(*execution_engine);
+    jit_memory_manager->ReportAllocations(*execution_engine_ap);
     jit_memory_manager->WriteData(*process);
     
     std::vector<JittedFunction>::iterator pos, end = m_jitted_functions.end();
@@ -697,8 +696,6 @@
         }
     }
     
-    execution_engine.reset();
-    
     err.Clear();
     return err;
 }





More information about the lldb-commits mailing list