[Lldb-commits] [lldb] r179702 - Made the IRInterpreter's methods static, since

Sean Callanan scallanan at apple.com
Wed Apr 17 11:07:40 PDT 2013


Author: spyffe
Date: Wed Apr 17 13:07:40 2013
New Revision: 179702

URL: http://llvm.org/viewvc/llvm-project?rev=179702&view=rev
Log:
Made the IRInterpreter's methods static, since
it doesn't actually hold any important state.

Modified:
    lldb/trunk/include/lldb/Expression/IRInterpreter.h
    lldb/trunk/source/Expression/IRForTarget.cpp
    lldb/trunk/source/Expression/IRInterpreter.cpp

Modified: lldb/trunk/include/lldb/Expression/IRInterpreter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/IRInterpreter.h?rev=179702&r1=179701&r2=179702&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/IRInterpreter.h (original)
+++ lldb/trunk/include/lldb/Expression/IRInterpreter.h Wed Apr 17 13:07:40 2013
@@ -41,26 +41,6 @@ class IRInterpreter
 {
 public:
     //------------------------------------------------------------------
-    /// Constructor
-    ///
-    /// @param[in] decl_map
-    ///     The list of externally-referenced variables for the expression,
-    ///     for use in looking up globals and allocating the argument
-    ///     struct.  See the documentation for ClangExpressionDeclMap.
-    ///
-    /// @param[in] error_stream
-    ///     If non-NULL, a stream on which errors can be printed.
-    //------------------------------------------------------------------
-    IRInterpreter(lldb_private::ClangExpressionDeclMap *decl_map,
-                  lldb_private::IRMemoryMap &memory_map,
-                  lldb_private::Stream *error_stream);
-    
-    //------------------------------------------------------------------
-    /// Destructor
-    //------------------------------------------------------------------
-    ~IRInterpreter();
-    
-    //------------------------------------------------------------------
     /// Run the IR interpreter on a single function
     ///
     /// @param[in] result
@@ -87,23 +67,26 @@ public:
     /// @return
     ///     True on success; false otherwise
     //------------------------------------------------------------------
-    bool 
-    maybeRunOnFunction (lldb::ClangExpressionVariableSP &result,
+    static bool
+    maybeRunOnFunction (lldb_private::ClangExpressionDeclMap *decl_map,
+                        lldb_private::IRMemoryMap &memory_map,
+                        lldb_private::Stream *error_stream,
+                        lldb::ClangExpressionVariableSP &result,
                         const lldb_private::ConstString &result_name,
                         lldb_private::TypeFromParser result_type,
                         llvm::Function &llvm_function,
                         llvm::Module &llvm_module,
                         lldb_private::Error &err);
-private:
-    lldb_private::ClangExpressionDeclMap   *m_decl_map;     ///< The DeclMap containing the Decls
-    lldb_private::IRMemoryMap              &m_memory_map;   ///< The IRMemoryMap to use when accessing memory
-    
-    bool
+private:   
+    static bool
     supportsFunction (llvm::Function &llvm_function,
                       lldb_private::Error &err);
     
-    bool 
-    runOnFunction (lldb::ClangExpressionVariableSP &result,
+    static bool
+    runOnFunction (lldb_private::ClangExpressionDeclMap *decl_map,
+                   lldb_private::IRMemoryMap &memory_map,
+                   lldb_private::Stream *error_stream,
+                   lldb::ClangExpressionVariableSP &result,
                    const lldb_private::ConstString &result_name,
                    lldb_private::TypeFromParser result_type,
                    llvm::Function &llvm_function,

Modified: lldb/trunk/source/Expression/IRForTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=179702&r1=179701&r2=179702&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRForTarget.cpp (original)
+++ lldb/trunk/source/Expression/IRForTarget.cpp Wed Apr 17 13:07:40 2013
@@ -2806,11 +2806,7 @@ IRForTarget::runOnModule (Module &llvm_m
     
     if (m_decl_map && m_execution_policy != lldb_private::eExecutionPolicyAlways)
     {
-        IRInterpreter interpreter (m_decl_map,
-                                   m_memory_map,
-                                   m_error_stream);
-
-        interpreter.maybeRunOnFunction(m_const_result, m_result_name, m_result_type, *function, llvm_module, m_interpreter_error);
+        IRInterpreter::maybeRunOnFunction(m_decl_map, m_memory_map, m_error_stream,m_const_result, m_result_name, m_result_type, *function, llvm_module, m_interpreter_error);
         
         if (m_interpreter_error.Success())
             return true;

Modified: lldb/trunk/source/Expression/IRInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRInterpreter.cpp?rev=179702&r1=179701&r2=179702&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRInterpreter.cpp (original)
+++ lldb/trunk/source/Expression/IRInterpreter.cpp Wed Apr 17 13:07:40 2013
@@ -26,20 +26,6 @@
 
 using namespace llvm;
 
-IRInterpreter::IRInterpreter(lldb_private::ClangExpressionDeclMap *decl_map,
-                             lldb_private::IRMemoryMap &memory_map,
-                             lldb_private::Stream *error_stream) :
-    m_decl_map(decl_map),
-    m_memory_map(memory_map)
-{
-    
-}
-
-IRInterpreter::~IRInterpreter()
-{
-    
-}
-
 static std::string 
 PrintValue(const Value *value, bool truncate = false)
 {
@@ -806,7 +792,10 @@ public:
 };
 
 bool
-IRInterpreter::maybeRunOnFunction (lldb::ClangExpressionVariableSP &result,
+IRInterpreter::maybeRunOnFunction (lldb_private::ClangExpressionDeclMap *decl_map,
+                                   lldb_private::IRMemoryMap &memory_map,
+                                   lldb_private::Stream *error_stream,
+                                   lldb::ClangExpressionVariableSP &result,
                                    const lldb_private::ConstString &result_name,
                                    lldb_private::TypeFromParser result_type,
                                    Function &llvm_function,
@@ -814,7 +803,10 @@ IRInterpreter::maybeRunOnFunction (lldb:
                                    lldb_private::Error &err)
 {
     if (supportsFunction (llvm_function, err))
-        return runOnFunction(result,
+        return runOnFunction(decl_map,
+                             memory_map,
+                             error_stream,
+                             result,
                              result_name, 
                              result_type, 
                              llvm_function,
@@ -927,7 +919,10 @@ IRInterpreter::supportsFunction (Functio
 }
 
 bool 
-IRInterpreter::runOnFunction (lldb::ClangExpressionVariableSP &result,
+IRInterpreter::runOnFunction (lldb_private::ClangExpressionDeclMap *decl_map,
+                              lldb_private::IRMemoryMap &memory_map,
+                              lldb_private::Stream *error_stream,
+                              lldb::ClangExpressionVariableSP &result,
                               const lldb_private::ConstString &result_name,
                               lldb_private::TypeFromParser result_type,
                               Function &llvm_function,
@@ -938,7 +933,7 @@ IRInterpreter::runOnFunction (lldb::Clan
     
     DataLayout target_data(&llvm_module);
     
-    InterpreterStackFrame frame(target_data, m_decl_map, m_memory_map);
+    InterpreterStackFrame frame(target_data, decl_map, memory_map);
 
     uint32_t num_insts = 0;
     
@@ -1117,7 +1112,7 @@ IRInterpreter::runOnFunction (lldb::Clan
                 
                 lldb_private::Error write_error;
                 
-                m_memory_map.WritePointerToMemory(P, R, write_error);
+                memory_map.WritePointerToMemory(P, R, write_error);
                 
                 if (!write_error.Success())
                 {
@@ -1126,8 +1121,8 @@ IRInterpreter::runOnFunction (lldb::Clan
                     err.SetErrorToGenericError();
                     err.SetErrorString(memory_write_error);
                     lldb_private::Error free_error;
-                    m_memory_map.Free(P, free_error);
-                    m_memory_map.Free(R, free_error);
+                    memory_map.Free(P, free_error);
+                    memory_map.Free(R, free_error);
                     return false;
                 }
                 
@@ -1514,7 +1509,7 @@ IRInterpreter::runOnFunction (lldb::Clan
                 
                 lldb::addr_t R;
                 lldb_private::Error read_error;
-                m_memory_map.ReadPointerFromMemory(&R, P, read_error);
+                memory_map.ReadPointerFromMemory(&R, P, read_error);
                 
                 if (!read_error.Success())
                 {
@@ -1529,7 +1524,7 @@ IRInterpreter::runOnFunction (lldb::Clan
                 lldb_private::DataBufferHeap buffer(target_size, 0);
                 
                 read_error.Clear();
-                m_memory_map.ReadMemory(buffer.GetBytes(), R, buffer.GetByteSize(), read_error);
+                memory_map.ReadMemory(buffer.GetBytes(), R, buffer.GetByteSize(), read_error);
                 if (!read_error.Success())
                 {
                     if (log)
@@ -1540,7 +1535,7 @@ IRInterpreter::runOnFunction (lldb::Clan
                 }
                 
                 lldb_private::Error write_error;
-                m_memory_map.WriteMemory(D, buffer.GetBytes(), buffer.GetByteSize(), write_error);
+                memory_map.WriteMemory(D, buffer.GetBytes(), buffer.GetByteSize(), write_error);
                 if (!write_error.Success())
                 {
                     if (log)
@@ -1630,7 +1625,7 @@ IRInterpreter::runOnFunction (lldb::Clan
                 
                 lldb::addr_t R;
                 lldb_private::Error read_error;
-                m_memory_map.ReadPointerFromMemory(&R, P, read_error);
+                memory_map.ReadPointerFromMemory(&R, P, read_error);
                 
                 if (!read_error.Success())
                 {
@@ -1645,7 +1640,7 @@ IRInterpreter::runOnFunction (lldb::Clan
                 lldb_private::DataBufferHeap buffer(target_size, 0);
                 
                 read_error.Clear();
-                m_memory_map.ReadMemory(buffer.GetBytes(), D, buffer.GetByteSize(), read_error);
+                memory_map.ReadMemory(buffer.GetBytes(), D, buffer.GetByteSize(), read_error);
                 if (!read_error.Success())
                 {
                     if (log)
@@ -1656,7 +1651,7 @@ IRInterpreter::runOnFunction (lldb::Clan
                 }
                 
                 lldb_private::Error write_error;
-                m_memory_map.WriteMemory(R, buffer.GetBytes(), buffer.GetByteSize(), write_error);
+                memory_map.WriteMemory(R, buffer.GetBytes(), buffer.GetByteSize(), write_error);
                 if (!write_error.Success())
                 {
                     if (log)





More information about the lldb-commits mailing list