Fixed an issue where StackFrame::GetValueForVariableExpressionPath(...)
was previously using the entire frame variable list instead of using the
in scope variable list. I added a new function to a stack frame:

	lldb::VariableListSP
	StackFrame::GetInScopeVariableList (bool get_file_globals);

This gets only variables that are in scope and they will be ordered such
that the variables from the current scope are first.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@136745 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Target/StackFrame.cpp b/source/Target/StackFrame.cpp
index 48055d0..803e49b 100644
--- a/source/Target/StackFrame.cpp
+++ b/source/Target/StackFrame.cpp
@@ -485,6 +485,34 @@
     return m_variable_list_sp.get();
 }
 
+VariableListSP
+StackFrame::GetInScopeVariableList (bool get_file_globals)
+{
+    VariableListSP var_list_sp(new VariableList);
+    GetSymbolContext (eSymbolContextCompUnit | eSymbolContextBlock);
+
+    if (m_sc.block)
+    {
+        const bool can_create = true;
+        const bool get_parent_variables = true;
+        const bool stop_if_block_is_inlined_function = true;
+        m_sc.block->AppendVariables (can_create, 
+                                     get_parent_variables,
+                                     stop_if_block_is_inlined_function,
+                                     var_list_sp.get());
+    }
+                     
+    if (m_sc.comp_unit)
+    {
+        VariableListSP global_variable_list_sp (m_sc.comp_unit->GetVariableList(true));
+        if (global_variable_list_sp)
+            var_list_sp->AddVariables (global_variable_list_sp.get());
+    }
+    
+    return var_list_sp;
+}
+
+
 ValueObjectSP
 StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, 
                                                lldb::DynamicValueType use_dynamic,
@@ -502,7 +530,10 @@
         bool address_of = false;
         ValueObjectSP valobj_sp;
         const bool get_file_globals = true;
-        VariableList *variable_list = GetVariableList (get_file_globals);
+        // When looking up a variable for an expression, we need only consider the
+        // variables that are in scope.
+        VariableListSP var_list_sp (GetInScopeVariableList (get_file_globals));
+        VariableList *variable_list = var_list_sp.get();
         
         if (variable_list)
         {