This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.

This modification touches the following files:

lldb-private-enumerations.h
  Introduce a new enum specifying the policy for
  processing an expression.  Some expressions should
  always be JITted, for example if they are functions
  that will be used over and over again.  Some
  expressions should always be interpreted, for
  example if the target is unsafe to run.  For most,
  it is acceptable to JIT them, but interpretation
  is preferable when possible.

Target.[h,cpp]
  Have EvaluateExpression now accept the new enum.

ClangExpressionDeclMap.[cpp,h]
  Add support for the IR interpreter and also make
  the ClangExpressionDeclMap more robust in the 
  absence of a process.

ClangFunction.[cpp,h]
  Add support for the new enum.

IRInterpreter.[cpp,h]
  New implementation.

ClangUserExpression.[cpp,h]
  Add support for the new enum, and for running 
  expressions in the absence of a process.

ClangExpression.h
  Remove references to the old DWARF-based method
  of evaluating expressions, because it has been
  superseded for now.

ClangUtilityFunction.[cpp,h]
  Add support for the new enum.

ClangExpressionParser.[cpp,h]
  Add support for the new enum, remove references
  to DWARF, and add support for checking whether
  the expression could be evaluated statically.

IRForTarget.[h,cpp]
  Add support for the new enum, and add utility
  functions to support the interpreter.

IRToDWARF.cpp
  Removed

CommandObjectExpression.cpp
  Remove references to the obsolete -i option.

Process.cpp 
  Modify calls to ClangUserExpression::Evaluate
  to pass the correct enum (for dlopen/dlclose)

SBValue.cpp
  Add support for the new enum.

SBFrame.cpp
  Add support for he new enum.

BreakpointOptions.cpp
  Add support for the new enum.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@139772 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/ClangExpressionParser.cpp b/source/Expression/ClangExpressionParser.cpp
index 81c03f3..921dc00 100644
--- a/source/Expression/ClangExpressionParser.cpp
+++ b/source/Expression/ClangExpressionParser.cpp
@@ -19,7 +19,6 @@
 #include "lldb/Expression/ClangExpression.h"
 #include "lldb/Expression/ClangExpressionDeclMap.h"
 #include "lldb/Expression/IRDynamicChecks.h"
-#include "lldb/Expression/IRToDWARF.h"
 #include "lldb/Expression/RecordingMemoryManager.h"
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/ObjCLanguageRuntime.h"
@@ -418,66 +417,14 @@
 }
 
 Error
-ClangExpressionParser::MakeDWARF ()
-{
-    Error err;
-    
-    llvm::Module *module = m_code_generator->GetModule();
-    
-    if (!module)
-    {
-        err.SetErrorToGenericError();
-        err.SetErrorString("IR doesn't contain a module");
-        return err;
-    }
-    
-    ClangExpressionVariableList *local_variables = m_expr.LocalVariables();
-    ClangExpressionDeclMap *decl_map = m_expr.DeclMap();
-    
-    if (!local_variables)
-    {
-        err.SetErrorToGenericError();
-        err.SetErrorString("Can't convert an expression without a VariableList to DWARF");
-        return err;
-    }
-    
-    if (!decl_map)
-    {
-        err.SetErrorToGenericError();
-        err.SetErrorString("Can't convert an expression without a DeclMap to DWARF");
-        return err;
-    }
-    
-    std::string function_name;
-    
-    if (!FindFunctionInModule(function_name, module, m_expr.FunctionName()))
-    {
-        err.SetErrorToGenericError();
-        err.SetErrorStringWithFormat("Couldn't find %s() in the module", m_expr.FunctionName());
-        return err;
-    }
-    
-    IRToDWARF ir_to_dwarf(*local_variables, decl_map, m_expr.DwarfOpcodeStream(), function_name.c_str());
-    
-    if (!ir_to_dwarf.runOnModule(*module))
-    {
-        err.SetErrorToGenericError();
-        err.SetErrorString("Couldn't convert the expression to DWARF");
-        return err;
-    }
-    
-    err.Clear();
-    return err;
-}
-
-Error
-ClangExpressionParser::MakeJIT (lldb::addr_t &func_allocation_addr, 
-                                lldb::addr_t &func_addr, 
-                                lldb::addr_t &func_end, 
-                                ExecutionContext &exe_ctx,
-                                IRForTarget::StaticDataAllocator *data_allocator,
-                                lldb::ClangExpressionVariableSP &const_result,
-                                bool jit_only_if_needed)
+ClangExpressionParser::PrepareForExecution (lldb::addr_t &func_allocation_addr, 
+                                            lldb::addr_t &func_addr, 
+                                            lldb::addr_t &func_end, 
+                                            ExecutionContext &exe_ctx,
+                                            IRForTarget::StaticDataAllocator *data_allocator,
+                                            bool &evaluated_statically,
+                                            lldb::ClangExpressionVariableSP &const_result,
+                                            ExecutionPolicy execution_policy)
 {
     func_allocation_addr = LLDB_INVALID_ADDRESS;
 	func_addr = LLDB_INVALID_ADDRESS;
@@ -520,8 +467,9 @@
         if (exe_ctx.target)
             error_stream = &exe_ctx.target->GetDebugger().GetErrorStream();
     
-        IRForTarget ir_for_target(decl_map, 
+        IRForTarget ir_for_target(decl_map,
                                   m_expr.NeedsVariableResolution(),
+                                  execution_policy,
                                   const_result,
                                   data_allocator,
                                   error_stream,
@@ -530,17 +478,25 @@
         if (!ir_for_target.runOnModule(*module))
         {
             err.SetErrorToGenericError();
-            err.SetErrorString("Couldn't convert the expression to DWARF");
+            err.SetErrorString("Couldn't prepare the expression for execution in the target");
             return err;
         }
         
-        if (jit_only_if_needed && const_result.get())
+        if (execution_policy != eExecutionPolicyAlways && ir_for_target.interpretSuccess())
         {
+            evaluated_statically = true;
             err.Clear();
             return err;
         }
         
-        if (m_expr.NeedsValidation() && exe_ctx.process->GetDynamicCheckers())
+        if (!exe_ctx.process || execution_policy == eExecutionPolicyNever)
+        {
+            err.SetErrorToGenericError();
+            err.SetErrorString("Execution needed to run in the target, but the target can't be run");
+            return err;
+        }
+        
+        if (m_expr.NeedsValidation() && exe_ctx.process && exe_ctx.process->GetDynamicCheckers())
         {
             IRDynamicChecks ir_dynamic_checks(*exe_ctx.process->GetDynamicCheckers(), function_name.c_str());