aboutsummaryrefslogtreecommitdiff
path: root/source/Symbol/Variable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Symbol/Variable.cpp')
-rw-r--r--source/Symbol/Variable.cpp106
1 files changed, 66 insertions, 40 deletions
diff --git a/source/Symbol/Variable.cpp b/source/Symbol/Variable.cpp
index 2490e98ac1e8..51d11b7ca8e9 100644
--- a/source/Symbol/Variable.cpp
+++ b/source/Symbol/Variable.cpp
@@ -15,10 +15,14 @@
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/Symbol/Block.h"
+#include "lldb/Symbol/CompilerDecl.h"
+#include "lldb/Symbol/CompilerDeclContext.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/Type.h"
+#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/ABI.h"
#include "lldb/Target/Process.h"
@@ -33,19 +37,17 @@ using namespace lldb_private;
//----------------------------------------------------------------------
// Variable constructor
//----------------------------------------------------------------------
-Variable::Variable
-(
- lldb::user_id_t uid,
- const char *name,
- const char *mangled, // The mangled or fully qualified name of the variable.
- const lldb::SymbolFileTypeSP &symfile_type_sp,
- ValueType scope,
- SymbolContextScope *context,
- Declaration* decl_ptr,
- const DWARFExpression& location,
- bool external,
- bool artificial
-) :
+Variable::Variable (lldb::user_id_t uid,
+ const char *name,
+ const char *mangled, // The mangled or fully qualified name of the variable.
+ const lldb::SymbolFileTypeSP &symfile_type_sp,
+ ValueType scope,
+ SymbolContextScope *context,
+ Declaration* decl_ptr,
+ const DWARFExpression& location,
+ bool external,
+ bool artificial,
+ bool static_member) :
UserID(uid),
m_name(name),
m_mangled (ConstString(mangled)),
@@ -55,7 +57,8 @@ Variable::Variable
m_declaration(decl_ptr),
m_location(location),
m_external(external),
- m_artificial(artificial)
+ m_artificial(artificial),
+ m_static_member(static_member)
{
}
@@ -87,6 +90,13 @@ Variable::GetName() const
return m_name;
}
+ConstString
+Variable::GetUnqualifiedName() const
+{
+ return m_name;
+}
+
+
bool
Variable::NameMatches (const ConstString &name) const
{
@@ -228,6 +238,22 @@ Variable::MemorySize() const
return sizeof(Variable);
}
+CompilerDeclContext
+Variable::GetDeclContext ()
+{
+ Type *type = GetType();
+ return type->GetSymbolFile()->GetDeclContextContainingUID(GetID());
+}
+
+CompilerDecl
+Variable::GetDecl ()
+{
+ Type *type = GetType();
+ CompilerDecl decl = type->GetSymbolFile()->GetDeclForUID(GetID());
+ if (decl)
+ decl.GetTypeSystem()->DeclLinkToObject(decl.GetOpaqueDecl(), shared_from_this());
+ return decl;
+}
void
Variable::CalculateSymbolContext (SymbolContext *sc)
@@ -558,7 +584,7 @@ static void
PrivateAutoComplete (StackFrame *frame,
const std::string &partial_path,
const std::string &prefix_path, // Anything that has been resolved already will be in here
- const ClangASTType& clang_type,
+ const CompilerType& compiler_type,
StringList &matches,
bool &word_complete);
@@ -567,7 +593,7 @@ PrivateAutoCompleteMembers (StackFrame *frame,
const std::string &partial_member_name,
const std::string &partial_path,
const std::string &prefix_path, // Anything that has been resolved already will be in here
- const ClangASTType& clang_type,
+ const CompilerType& compiler_type,
StringList &matches,
bool &word_complete);
@@ -576,19 +602,19 @@ PrivateAutoCompleteMembers (StackFrame *frame,
const std::string &partial_member_name,
const std::string &partial_path,
const std::string &prefix_path, // Anything that has been resolved already will be in here
- const ClangASTType& clang_type,
+ const CompilerType& compiler_type,
StringList &matches,
bool &word_complete)
{
// We are in a type parsing child members
- const uint32_t num_bases = clang_type.GetNumDirectBaseClasses();
+ const uint32_t num_bases = compiler_type.GetNumDirectBaseClasses();
if (num_bases > 0)
{
for (uint32_t i = 0; i < num_bases; ++i)
{
- ClangASTType base_class_type (clang_type.GetDirectBaseClassAtIndex (i, nullptr));
+ CompilerType base_class_type = compiler_type.GetDirectBaseClassAtIndex(i, nullptr);
PrivateAutoCompleteMembers (frame,
partial_member_name,
@@ -600,13 +626,13 @@ PrivateAutoCompleteMembers (StackFrame *frame,
}
}
- const uint32_t num_vbases = clang_type.GetNumVirtualBaseClasses();
+ const uint32_t num_vbases = compiler_type.GetNumVirtualBaseClasses();
if (num_vbases > 0)
{
for (uint32_t i = 0; i < num_vbases; ++i)
{
- ClangASTType vbase_class_type (clang_type.GetVirtualBaseClassAtIndex(i,nullptr));
+ CompilerType vbase_class_type = compiler_type.GetVirtualBaseClassAtIndex(i,nullptr);
PrivateAutoCompleteMembers (frame,
partial_member_name,
@@ -619,7 +645,7 @@ PrivateAutoCompleteMembers (StackFrame *frame,
}
// We are in a type parsing child members
- const uint32_t num_fields = clang_type.GetNumFields();
+ const uint32_t num_fields = compiler_type.GetNumFields();
if (num_fields > 0)
{
@@ -627,7 +653,7 @@ PrivateAutoCompleteMembers (StackFrame *frame,
{
std::string member_name;
- ClangASTType member_clang_type = clang_type.GetFieldAtIndex (i, member_name, nullptr, nullptr, nullptr);
+ CompilerType member_compiler_type = compiler_type.GetFieldAtIndex (i, member_name, nullptr, nullptr, nullptr);
if (partial_member_name.empty() ||
member_name.find(partial_member_name) == 0)
@@ -637,7 +663,7 @@ PrivateAutoCompleteMembers (StackFrame *frame,
PrivateAutoComplete (frame,
partial_path,
prefix_path + member_name, // Anything that has been resolved already will be in here
- member_clang_type.GetCanonicalType(),
+ member_compiler_type.GetCanonicalType(),
matches,
word_complete);
}
@@ -654,17 +680,17 @@ static void
PrivateAutoComplete (StackFrame *frame,
const std::string &partial_path,
const std::string &prefix_path, // Anything that has been resolved already will be in here
- const ClangASTType& clang_type,
+ const CompilerType& compiler_type,
StringList &matches,
bool &word_complete)
{
// printf ("\nPrivateAutoComplete()\n\tprefix_path = '%s'\n\tpartial_path = '%s'\n", prefix_path.c_str(), partial_path.c_str());
std::string remaining_partial_path;
- const lldb::TypeClass type_class = clang_type.GetTypeClass();
+ const lldb::TypeClass type_class = compiler_type.GetTypeClass();
if (partial_path.empty())
{
- if (clang_type.IsValid())
+ if (compiler_type.IsValid())
{
switch (type_class)
{
@@ -700,7 +726,7 @@ PrivateAutoComplete (StackFrame *frame,
case eTypeClassPointer:
{
bool omit_empty_base_classes = true;
- if (clang_type.GetNumChildren (omit_empty_base_classes) > 0)
+ if (compiler_type.GetNumChildren (omit_empty_base_classes) > 0)
matches.AppendString (prefix_path + "->");
else
{
@@ -742,7 +768,7 @@ PrivateAutoComplete (StackFrame *frame,
PrivateAutoComplete (frame,
partial_path.substr(1),
std::string("*"),
- clang_type,
+ compiler_type,
matches,
word_complete);
}
@@ -754,7 +780,7 @@ PrivateAutoComplete (StackFrame *frame,
PrivateAutoComplete (frame,
partial_path.substr(1),
std::string("&"),
- clang_type,
+ compiler_type,
matches,
word_complete);
}
@@ -767,7 +793,7 @@ PrivateAutoComplete (StackFrame *frame,
{
case lldb::eTypeClassPointer:
{
- ClangASTType pointee_type(clang_type.GetPointeeType());
+ CompilerType pointee_type(compiler_type.GetPointeeType());
if (partial_path[2])
{
// If there is more after the "->", then search deeper
@@ -797,7 +823,7 @@ PrivateAutoComplete (StackFrame *frame,
break;
case '.':
- if (clang_type.IsValid())
+ if (compiler_type.IsValid())
{
switch (type_class)
{
@@ -810,7 +836,7 @@ PrivateAutoComplete (StackFrame *frame,
PrivateAutoComplete (frame,
partial_path.substr(1),
prefix_path + ".",
- clang_type,
+ compiler_type,
matches,
word_complete);
@@ -822,7 +848,7 @@ PrivateAutoComplete (StackFrame *frame,
std::string(),
partial_path,
prefix_path + ".",
- clang_type,
+ compiler_type,
matches,
word_complete);
}
@@ -850,13 +876,13 @@ PrivateAutoComplete (StackFrame *frame,
std::string token(partial_path, 0, pos);
remaining_partial_path = partial_path.substr(pos);
- if (clang_type.IsValid())
+ if (compiler_type.IsValid())
{
PrivateAutoCompleteMembers (frame,
token,
remaining_partial_path,
prefix_path,
- clang_type,
+ compiler_type,
matches,
word_complete);
}
@@ -886,11 +912,11 @@ PrivateAutoComplete (StackFrame *frame,
Type *variable_type = variable->GetType();
if (variable_type)
{
- ClangASTType variable_clang_type (variable_type->GetClangForwardType());
+ CompilerType variable_compiler_type (variable_type->GetForwardCompilerType ());
PrivateAutoComplete (frame,
remaining_partial_path,
prefix_path + token, // Anything that has been resolved already will be in here
- variable_clang_type.GetCanonicalType(),
+ variable_compiler_type.GetCanonicalType(),
matches,
word_complete);
}
@@ -923,14 +949,14 @@ Variable::AutoComplete (const ExecutionContext &exe_ctx,
word_complete = false;
std::string partial_path;
std::string prefix_path;
- ClangASTType clang_type;
+ CompilerType compiler_type;
if (partial_path_cstr && partial_path_cstr[0])
partial_path = partial_path_cstr;
PrivateAutoComplete (exe_ctx.GetFramePtr(),
partial_path,
prefix_path,
- clang_type,
+ compiler_type,
matches,
word_complete);