summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Expression/ClangExpressionVariable.h68
-rw-r--r--lldb/source/Expression/ClangExpressionVariable.cpp21
2 files changed, 63 insertions, 26 deletions
diff --git a/lldb/include/lldb/Expression/ClangExpressionVariable.h b/lldb/include/lldb/Expression/ClangExpressionVariable.h
index fc6cccced11..6461932e969 100644
--- a/lldb/include/lldb/Expression/ClangExpressionVariable.h
+++ b/lldb/include/lldb/Expression/ClangExpressionVariable.h
@@ -24,33 +24,83 @@
namespace lldb_private {
+//----------------------------------------------------------------------
+/// @class ClangExpressionVariableList ClangExpressionVariable.h "lldb/Expression/ClangExpressionVariable.h"
+/// @brief Manages local variables that the expression interpreter uses.
+///
+/// The DWARF interpreter, when interpreting expressions, occasionally
+/// needs to interact with chunks of memory corresponding to local variable
+/// values. These locals are distinct from the externally-defined values
+/// handled by ClangExpressionDeclMap, and do not persist between expressions
+/// so they are not handled by ClangPersistentVariables. They are kept in a
+/// list, which is encapsulated in ClangEpxressionVariableList.
+//----------------------------------------------------------------------
class ClangExpressionVariableList
{
public:
+ //----------------------------------------------------------------------
+ /// Constructor
+ //----------------------------------------------------------------------
ClangExpressionVariableList();
+
+ //----------------------------------------------------------------------
+ /// Destructor
+ //----------------------------------------------------------------------
~ClangExpressionVariableList();
+ //----------------------------------------------------------------------
+ /// Get or create the chunk of data corresponding to a given VarDecl.
+ ///
+ /// @param[in] var_decl
+ /// The Decl for which a chunk of memory is to be allocated.
+ ///
+ /// @param[out] idx
+ /// The index of the Decl in the list of variables.
+ ///
+ /// @param[in] can_create
+ /// True if the memory should be created if necessary.
+ ///
+ /// @return
+ /// A Value for the allocated memory. NULL if the Decl couldn't be
+ /// found and can_create was false, or if some error occurred during
+ /// allocation.
+ //----------------------------------------------------------------------
Value *
- GetVariableForVarDecl (clang::ASTContext &ast_context,
- const clang::VarDecl *var_decl,
+ GetVariableForVarDecl (const clang::VarDecl *var_decl,
uint32_t& idx,
bool can_create);
+ //----------------------------------------------------------------------
+ /// Get the chunk of data corresponding to a given index into the list.
+ ///
+ /// @param[in] idx
+ /// The index of the Decl in the list of variables.
+ ///
+ /// @return
+ /// The value at the given index, or NULL if there is none.
+ //----------------------------------------------------------------------
Value *
GetVariableAtIndex (uint32_t idx);
-
- uint32_t
- AppendValue (Value *value); // takes ownership
-
private:
+ //----------------------------------------------------------------------
+ /// @class ClangExpressionVariable ClangExpressionVariable.h "lldb/Expression/ClangExpressionVariable.h"
+ /// @brief Manages one local variable for the expression interpreter.
+ ///
+ /// The expression interpreter uses specially-created Values to hold its
+ /// temporary locals. These Values contain data buffers holding enough
+ /// space to contain a variable of the appropriate type. The VarDecls
+ /// are only used while creating the list and generating the DWARF code for
+ /// an expression; when interpreting the DWARF, the variables are identified
+ /// only by their index into the list of variables.
+ //----------------------------------------------------------------------
struct ClangExpressionVariable
{
- const clang::VarDecl *m_var_decl;
- Value *m_value;
+ const clang::VarDecl *m_var_decl; ///< The VarDecl corresponding to the parsed local.
+ Value *m_value; ///< The LLDB Value containing the data for the local.
};
typedef std::vector<ClangExpressionVariable> Variables;
- Variables m_variables;
+ Variables m_variables; ///< The list of variables used by the expression.
};
} // namespace lldb_private
diff --git a/lldb/source/Expression/ClangExpressionVariable.cpp b/lldb/source/Expression/ClangExpressionVariable.cpp
index 40fee4b47f5..dce0316983c 100644
--- a/lldb/source/Expression/ClangExpressionVariable.cpp
+++ b/lldb/source/Expression/ClangExpressionVariable.cpp
@@ -33,14 +33,14 @@ ClangExpressionVariableList::~ClangExpressionVariableList()
}
Value *
-ValueForDecl(ASTContext &ast_context, const VarDecl *var_decl)
+ValueForDecl(const VarDecl *var_decl)
{
Value *ret = new Value;
ret->SetContext(Value::eContextTypeOpaqueClangQualType,
var_decl->getType().getAsOpaquePtr());
- uint64_t bit_width = ast_context.getTypeSize(var_decl->getType());
+ uint64_t bit_width = var_decl->getASTContext().getTypeSize(var_decl->getType());
uint32_t byte_size = (bit_width + 7 ) / 8;
@@ -50,7 +50,7 @@ ValueForDecl(ASTContext &ast_context, const VarDecl *var_decl)
}
Value *
-ClangExpressionVariableList::GetVariableForVarDecl (ASTContext &ast_context, const VarDecl *var_decl, uint32_t& idx, bool can_create)
+ClangExpressionVariableList::GetVariableForVarDecl (const VarDecl *var_decl, uint32_t& idx, bool can_create)
{
uint32_t num_variables = m_variables.size();
uint32_t var_index;
@@ -71,7 +71,7 @@ ClangExpressionVariableList::GetVariableForVarDecl (ASTContext &ast_context, con
ClangExpressionVariable val;
val.m_var_decl = var_decl;
- val.m_value = ValueForDecl(ast_context, var_decl);
+ val.m_value = ValueForDecl(var_decl);
m_variables.push_back(val);
return m_variables.back().m_value;
@@ -85,16 +85,3 @@ ClangExpressionVariableList::GetVariableAtIndex (uint32_t idx)
return NULL;
}
-
-uint32_t
-ClangExpressionVariableList::AppendValue (Value *value)
-{
- uint32_t idx = m_variables.size();
-
- ClangExpressionVariable val;
- val.m_var_decl = NULL;
- val.m_value = value;
-
- m_variables.push_back(val);
- return idx;
-}
OpenPOWER on IntegriCloud