Testcase and fix for bug 24074

Summary:
In bug 24074, the type information is not shown
correctly. This commit  includes the following -
-> Changes for displaying correct type based on
   current lexical scope for the command "image
   lookup -t"
-> The corresponding testcase.

Reviewers: jingham, ovyalov, spyffe, richard.mitton, clayborg

Differential Revision: http://reviews.llvm.org/D12404

llvm-svn: 248366
This commit is contained in:
Ravitheja Addepally
2015-09-23 07:19:02 +00:00
parent 77b94d4416
commit 9fcf72ef9b
22 changed files with 749 additions and 74 deletions

View File

@@ -36,6 +36,7 @@
#include "lldb/Target/Target.h"
#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
#include "Plugins/Language/ObjC/ObjCLanguage.h"
#include "lldb/Symbol/TypeMap.h"
#include "Plugins/ObjectFile/JIT/ObjectFileJIT.h"
@@ -940,7 +941,7 @@ Module::FindTypes_Impl (const SymbolContext& sc,
const CompilerDeclContext *parent_decl_ctx,
bool append,
size_t max_matches,
TypeList& types)
TypeMap& types)
{
Timer scoped_timer(__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
if (sc.module_sp.get() == NULL || sc.module_sp.get() == this)
@@ -960,7 +961,11 @@ Module::FindTypesInNamespace (const SymbolContext& sc,
TypeList& type_list)
{
const bool append = true;
return FindTypes_Impl(sc, type_name, parent_decl_ctx, append, max_matches, type_list);
TypeMap types_map;
size_t num_types = FindTypes_Impl(sc, type_name, parent_decl_ctx, append, max_matches, types_map);
if (num_types > 0)
sc.SortTypeList(types_map, type_list);
return num_types;
}
lldb::TypeSP
@@ -989,6 +994,7 @@ Module::FindTypes (const SymbolContext& sc,
std::string type_basename;
const bool append = true;
TypeClass type_class = eTypeClassAny;
TypeMap typesmap;
if (Type::GetTypeScopeAndBasename (type_name_cstr, type_scope, type_basename, type_class))
{
// Check if "name" starts with "::" which means the qualified type starts
@@ -1002,10 +1008,10 @@ Module::FindTypes (const SymbolContext& sc,
exact_match = true;
}
ConstString type_basename_const_str (type_basename.c_str());
if (FindTypes_Impl(sc, type_basename_const_str, NULL, append, max_matches, types))
if (FindTypes_Impl(sc, type_basename_const_str, NULL, append, max_matches, typesmap))
{
types.RemoveMismatchedTypes (type_scope, type_basename, type_class, exact_match);
num_matches = types.GetSize();
typesmap.RemoveMismatchedTypes (type_scope, type_basename, type_class, exact_match);
num_matches = typesmap.GetSize();
}
}
else
@@ -1015,18 +1021,18 @@ Module::FindTypes (const SymbolContext& sc,
{
// The "type_name_cstr" will have been modified if we have a valid type class
// prefix (like "struct", "class", "union", "typedef" etc).
FindTypes_Impl(sc, ConstString(type_name_cstr), NULL, append, max_matches, types);
types.RemoveMismatchedTypes (type_class);
num_matches = types.GetSize();
FindTypes_Impl(sc, ConstString(type_name_cstr), NULL, append, max_matches, typesmap);
typesmap.RemoveMismatchedTypes (type_class);
num_matches = typesmap.GetSize();
}
else
{
num_matches = FindTypes_Impl(sc, name, NULL, append, max_matches, types);
num_matches = FindTypes_Impl(sc, name, NULL, append, max_matches, typesmap);
}
}
if (num_matches > 0)
sc.SortTypeList(typesmap, types);
return num_matches;
}
SymbolVendor*