[Lldb-commits] [lldb] r111053 - in /lldb/trunk: include/lldb/Expression/ClangExpressionVariable.h source/Expression/ClangExpressionVariable.cpp
Sean Callanan
scallanan at apple.com
Fri Aug 13 15:52:29 PDT 2010
Author: spyffe
Date: Fri Aug 13 17:52:29 2010
New Revision: 111053
URL: http://llvm.org/viewvc/llvm-project?rev=111053&view=rev
Log:
Documented ClangExpressionVariable(List), and
cleaned up its API slightly.
Modified:
lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h
lldb/trunk/source/Expression/ClangExpressionVariable.cpp
Modified: lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h?rev=111053&r1=111052&r2=111053&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h (original)
+++ lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h Fri Aug 13 17:52:29 2010
@@ -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
Modified: lldb/trunk/source/Expression/ClangExpressionVariable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionVariable.cpp?rev=111053&r1=111052&r2=111053&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionVariable.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionVariable.cpp Fri Aug 13 17:52:29 2010
@@ -33,14 +33,14 @@
}
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 @@
}
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 @@
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 @@
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;
-}
More information about the lldb-commits
mailing list