[Symbol] Improve Variable::GetLanguage

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
This commit is contained in:
Alex Langford 2019-07-22 20:14:18 +00:00
parent 510e6fadaa
commit 4de5d9d612
2 changed files with 14 additions and 14 deletions

View File

@ -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;

View File

@ -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;
}