[Lldb-commits] [PATCH] D64042: [Symbol] Improve Variable::GetLanguage
Alex Langford via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon Jul 1 15:36:02 PDT 2019
xiaobai created this revision.
xiaobai added reviewers: jingham, clayborg.
Herald added a subscriber: jdoerfert.
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.
https://reviews.llvm.org/D64042
Files:
source/Core/ValueObject.cpp
source/Symbol/Variable.cpp
Index: source/Symbol/Variable.cpp
===================================================================
--- source/Symbol/Variable.cpp
+++ source/Symbol/Variable.cpp
@@ -54,10 +54,18 @@
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;
}
Index: source/Core/ValueObject.cpp
===================================================================
--- source/Core/ValueObject.cpp
+++ source/Core/ValueObject.cpp
@@ -1703,16 +1703,7 @@
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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64042.207422.patch
Type: text/x-patch
Size: 1806 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190701/86983978/attachment.bin>
More information about the lldb-commits
mailing list