From 69b5341c6aa85cd178ef199f58b2a57526554ad9 Mon Sep 17 00:00:00 2001 From: Sean Callanan Date: Sat, 6 Aug 2011 00:28:14 +0000 Subject: [PATCH] Made the expression parser use the StackFrame's variable search API rather than rolling its own, fixing one of our testcases. llvm-svn: 137004 --- .../Expression/ClangExpressionDeclMap.cpp | 54 +++++++------------ .../TestIndexVariable.py | 1 - 2 files changed, 20 insertions(+), 35 deletions(-) diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp index f4598dd364a1..f3f4b022cdf0 100644 --- a/lldb/source/Expression/ClangExpressionDeclMap.cpp +++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp @@ -1572,40 +1572,18 @@ ClangExpressionDeclMap::FindVariableInScope { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - VariableList *var_list = frame.GetVariableList(true); + ValueObjectSP valobj; + VariableSP var_sp; + Error err; - if (!var_list) - return lldb::VariableSP(); - - lldb::VariableSP var_sp (var_list->FindVariable(name)); + valobj = frame.GetValueForVariableExpressionPath(name.GetCString(), + eNoDynamicValues, + StackFrame::eExpressionPathOptionCheckPtrVsMember, + var_sp, + err); - const bool append = true; - const uint32_t max_matches = 1; - if (!var_sp) - { - // Look for globals elsewhere in the module for the frame - ModuleSP module_sp (frame.GetSymbolContext(eSymbolContextModule).module_sp); - if (module_sp) - { - VariableList module_globals; - if (module_sp->FindGlobalVariables (name, append, max_matches, module_globals)) - var_sp = module_globals.GetVariableAtIndex (0); - } - } - - if (!var_sp) - { - // Look for globals elsewhere in the program (all images) - TargetSP target_sp (frame.GetSymbolContext(eSymbolContextTarget).target_sp); - if (target_sp) - { - VariableList program_globals; - if (target_sp->GetImages().FindGlobalVariables (name, append, max_matches, program_globals)) - var_sp = program_globals.GetVariableAtIndex (0); - } - } - - if (!var_sp || + if (!err.Success() || + !var_sp || !var_sp->IsInScope(&frame) || !var_sp->LocationIsValidForFrame (&frame)) return lldb::VariableSP(); @@ -1745,10 +1723,18 @@ ClangExpressionDeclMap::GetDecls (NameSearchContext &context, const ConstString // doesn't start with our phony prefix of '$' if (name_unique_cstr[0] != '$') { - VariableSP var = FindVariableInScope(*m_parser_vars->m_exe_ctx->frame, name); + ValueObjectSP valobj; + VariableSP var; + Error err; + + valobj = m_parser_vars->m_exe_ctx->frame->GetValueForVariableExpressionPath(name_unique_cstr, + eNoDynamicValues, + StackFrame::eExpressionPathOptionCheckPtrVsMember, + var, + err); // If we found a variable in scope, no need to pull up function names - if (var != NULL) + if (err.Success() && var != NULL) { AddOneVariable(context, var); } diff --git a/lldb/test/functionalities/non-overlapping-index-variable-i/TestIndexVariable.py b/lldb/test/functionalities/non-overlapping-index-variable-i/TestIndexVariable.py index 9e93677f3f88..92ff0e6e62cf 100644 --- a/lldb/test/functionalities/non-overlapping-index-variable-i/TestIndexVariable.py +++ b/lldb/test/functionalities/non-overlapping-index-variable-i/TestIndexVariable.py @@ -15,7 +15,6 @@ class NonOverlappingIndexVariableCase(TestBase): self.line_to_break = line_number(self.source, '// Set breakpoint here.') # rdar://problem/9890530 - @unittest2.expectedFailure def test_eval_index_variable(self): """Test expressions of variable 'i' which appears in two for loops.""" self.buildDefault()