Skip to content

Commit

Permalink
[Symbol] Improve Variable::GetLanguage
Browse files Browse the repository at this point in the history
Summary:
When trying to ascertain what language a variable belongs to, just
checking the compilation unit is often not enough. In r364845 I added a way to
check for a variable's language type, but didn't put it in Variable itself.
Let's go ahead and put it in Variable.

Reviewers: jingham, clayborg

Subscribers: jdoerfert, lldb-commits

Differential Revision: https://reviews.llvm.org/D64042

llvm-svn: 366733
  • Loading branch information
bulbazord committed Jul 22, 2019
1 parent 510e6fa commit 4de5d9d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
11 changes: 1 addition & 10 deletions lldb/source/Core/ValueObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1672,16 +1672,7 @@ bool ValueObject::IsRuntimeSupportValue() {
if (!GetVariable() || !GetVariable()->IsArtificial())
return false;

LanguageType lang = eLanguageTypeUnknown;
if (auto *sym_ctx_scope = GetSymbolContextScope()) {
if (auto *func = sym_ctx_scope->CalculateSymbolContextFunction())
lang = func->GetLanguage();
else if (auto *comp_unit =
sym_ctx_scope->CalculateSymbolContextCompileUnit())
lang = comp_unit->GetLanguage();
}

if (auto *runtime = process->GetLanguageRuntime(lang))
if (auto *runtime = process->GetLanguageRuntime(GetVariable()->GetLanguage()))
if (runtime->IsWhitelistedRuntimeValue(GetName()))
return false;

Expand Down
17 changes: 13 additions & 4 deletions lldb/source/Symbol/Variable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,19 @@ Variable::Variable(
Variable::~Variable() {}

lldb::LanguageType Variable::GetLanguage() const {
SymbolContext variable_sc;
m_owner_scope->CalculateSymbolContext(&variable_sc);
if (variable_sc.comp_unit)
return variable_sc.comp_unit->GetLanguage();
lldb::LanguageType lang = m_mangled.GuessLanguage();
if (lang != lldb::eLanguageTypeUnknown)
return lang;

if (auto *func = m_owner_scope->CalculateSymbolContextFunction()) {
if ((lang = func->GetLanguage()) && lang != lldb::eLanguageTypeUnknown)
return lang;
else if (auto *comp_unit =
m_owner_scope->CalculateSymbolContextCompileUnit())
if ((lang = func->GetLanguage()) && lang != lldb::eLanguageTypeUnknown)
return lang;
}

return lldb::eLanguageTypeUnknown;
}

Expand Down

0 comments on commit 4de5d9d

Please sign in to comment.