summaryrefslogtreecommitdiff
path: root/source/Symbol/Variable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Symbol/Variable.cpp')
-rw-r--r--source/Symbol/Variable.cpp37
1 files changed, 28 insertions, 9 deletions
diff --git a/source/Symbol/Variable.cpp b/source/Symbol/Variable.cpp
index 51d11b7ca8e9..dd27b1b5d802 100644
--- a/source/Symbol/Variable.cpp
+++ b/source/Symbol/Variable.cpp
@@ -43,6 +43,7 @@ Variable::Variable (lldb::user_id_t uid,
const lldb::SymbolFileTypeSP &symfile_type_sp,
ValueType scope,
SymbolContextScope *context,
+ const RangeList& scope_range,
Declaration* decl_ptr,
const DWARFExpression& location,
bool external,
@@ -54,6 +55,7 @@ Variable::Variable (lldb::user_id_t uid,
m_symfile_type_sp(symfile_type_sp),
m_scope(scope),
m_owner_scope(context),
+ m_scope_range(scope_range),
m_declaration(decl_ptr),
m_location(location),
m_external(external),
@@ -155,8 +157,13 @@ Variable::Dump(Stream *s, bool show_context) const
switch (m_scope)
{
case eValueTypeVariableGlobal: s->PutCString(m_external ? "global" : "static"); break;
- case eValueTypeVariableArgument: s->PutCString("parameter"); break;
+ case eValueTypeVariableArgument:
+ s->PutCString("parameter");
+ break;
case eValueTypeVariableLocal: s->PutCString("local"); break;
+ case eValueTypeVariableThreadLocal:
+ s->PutCString("thread local");
+ break;
default: *s << "??? (" << m_scope << ')';
}
}
@@ -242,17 +249,16 @@ CompilerDeclContext
Variable::GetDeclContext ()
{
Type *type = GetType();
- return type->GetSymbolFile()->GetDeclContextContainingUID(GetID());
+ if (type)
+ return type->GetSymbolFile()->GetDeclContextContainingUID(GetID());
+ return CompilerDeclContext();
}
CompilerDecl
Variable::GetDecl ()
{
Type *type = GetType();
- CompilerDecl decl = type->GetSymbolFile()->GetDeclForUID(GetID());
- if (decl)
- decl.GetTypeSystem()->DeclLinkToObject(decl.GetOpaqueDecl(), shared_from_this());
- return decl;
+ return type ? type->GetSymbolFile()->GetDeclForUID(GetID()) : CompilerDecl();
}
void
@@ -343,6 +349,7 @@ Variable::IsInScope (StackFrame *frame)
case eValueTypeConstResult:
case eValueTypeVariableGlobal:
case eValueTypeVariableStatic:
+ case eValueTypeVariableThreadLocal:
return true;
case eValueTypeVariableArgument:
@@ -356,14 +363,24 @@ Variable::IsInScope (StackFrame *frame)
{
SymbolContext variable_sc;
CalculateSymbolContext (&variable_sc);
+
// Check for static or global variable defined at the compile unit
// level that wasn't defined in a block
if (variable_sc.block == nullptr)
- return true;
+ return true;
- if (variable_sc.block == deepest_frame_block)
+ // Check if the variable is valid in the current block
+ if (variable_sc.block != deepest_frame_block &&
+ !variable_sc.block->Contains(deepest_frame_block))
+ return false;
+
+ // If no scope range is specified then it means that the scope is the same as the
+ // scope of the enclosing lexical block.
+ if (m_scope_range.IsEmpty())
return true;
- return variable_sc.block->Contains (deepest_frame_block);
+
+ addr_t file_address = frame->GetFrameCodeAddress().GetFileAddress();
+ return m_scope_range.FindEntryThatContains(file_address) != nullptr;
}
}
break;
@@ -816,6 +833,7 @@ PrivateAutoComplete (StackFrame *frame,
word_complete);
}
}
+ break;
default:
break;
}
@@ -852,6 +870,7 @@ PrivateAutoComplete (StackFrame *frame,
matches,
word_complete);
}
+ break;
default:
break;
}