Skip to content

Commit 4de5d9d

Browse files
committed
[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
1 parent 510e6fa commit 4de5d9d

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

lldb/source/Core/ValueObject.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,16 +1672,7 @@ bool ValueObject::IsRuntimeSupportValue() {
16721672
if (!GetVariable() || !GetVariable()->IsArtificial())
16731673
return false;
16741674

1675-
LanguageType lang = eLanguageTypeUnknown;
1676-
if (auto *sym_ctx_scope = GetSymbolContextScope()) {
1677-
if (auto *func = sym_ctx_scope->CalculateSymbolContextFunction())
1678-
lang = func->GetLanguage();
1679-
else if (auto *comp_unit =
1680-
sym_ctx_scope->CalculateSymbolContextCompileUnit())
1681-
lang = comp_unit->GetLanguage();
1682-
}
1683-
1684-
if (auto *runtime = process->GetLanguageRuntime(lang))
1675+
if (auto *runtime = process->GetLanguageRuntime(GetVariable()->GetLanguage()))
16851676
if (runtime->IsWhitelistedRuntimeValue(GetName()))
16861677
return false;
16871678

lldb/source/Symbol/Variable.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,19 @@ Variable::Variable(
5454
Variable::~Variable() {}
5555

5656
lldb::LanguageType Variable::GetLanguage() const {
57-
SymbolContext variable_sc;
58-
m_owner_scope->CalculateSymbolContext(&variable_sc);
59-
if (variable_sc.comp_unit)
60-
return variable_sc.comp_unit->GetLanguage();
57+
lldb::LanguageType lang = m_mangled.GuessLanguage();
58+
if (lang != lldb::eLanguageTypeUnknown)
59+
return lang;
60+
61+
if (auto *func = m_owner_scope->CalculateSymbolContextFunction()) {
62+
if ((lang = func->GetLanguage()) && lang != lldb::eLanguageTypeUnknown)
63+
return lang;
64+
else if (auto *comp_unit =
65+
m_owner_scope->CalculateSymbolContextCompileUnit())
66+
if ((lang = func->GetLanguage()) && lang != lldb::eLanguageTypeUnknown)
67+
return lang;
68+
}
69+
6170
return lldb::eLanguageTypeUnknown;
6271
}
6372

0 commit comments

Comments
 (0)