[Lldb-commits] [lldb] r366733 - [Symbol] Improve Variable::GetLanguage
Alex Langford via lldb-commits
lldb-commits at lists.llvm.org
Mon Jul 22 13:14:18 PDT 2019
Author: xiaobai
Date: Mon Jul 22 13:14:18 2019
New Revision: 366733
URL: http://llvm.org/viewvc/llvm-project?rev=366733&view=rev
Log:
[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
Modified:
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/source/Symbol/Variable.cpp
Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=366733&r1=366732&r2=366733&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Mon Jul 22 13:14:18 2019
@@ -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;
Modified: lldb/trunk/source/Symbol/Variable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Variable.cpp?rev=366733&r1=366732&r2=366733&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Variable.cpp (original)
+++ lldb/trunk/source/Symbol/Variable.cpp Mon Jul 22 13:14:18 2019
@@ -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;
}
More information about the lldb-commits
mailing list