Use uniqueness of C++ fully-qualified names to resolve conflicts
A very expected layout: source tree is in ~/src/llvm, the build directory is in ~/src/llvm-build, and the install location is in /usr/local/{lib,include}. The DWARF information in /usr/local/lib/libLLVM.a for ilist.h points to ~/src/llvm-build/include/llvm/ADT/ilist.h. Now, when someone includes "llvm/ADT/ilist.h" and links against /usr/local/lib/libLLVM.a. Disaster. The DWARF information in libUser.so for ilist.h points to two locations: the one in /usr/include, and the one in ~/src/llvm-build/include. LLDB gets confused. Let's uniquify fully-qualified names and never trip on such a thing. Differential Revision: http://reviews.llvm.org/D14549 llvm-svn: 252898
This commit is contained in:
parent
7384a2de02
commit
314b752513
|
@ -457,19 +457,21 @@ DWARFASTParserClang::ParseTypeFromDWARF (const SymbolContext& sc,
|
|||
// and clang isn't good and sharing the stack space for variables in different blocks.
|
||||
std::unique_ptr<UniqueDWARFASTType> unique_ast_entry_ap(new UniqueDWARFASTType());
|
||||
|
||||
// Only try and unique the type if it has a name.
|
||||
if (type_name_const_str &&
|
||||
dwarf->GetUniqueDWARFASTTypeMap().Find (type_name_const_str,
|
||||
die,
|
||||
decl,
|
||||
if (type_name_const_str)
|
||||
{
|
||||
LanguageType die_language = die.GetLanguage();
|
||||
bool handled = false;
|
||||
if (Language::LanguageIsCPlusPlus(die_language))
|
||||
{
|
||||
std::string qualified_name;
|
||||
if (die.GetQualifiedName(qualified_name))
|
||||
{
|
||||
handled = true;
|
||||
ConstString const_qualified_name(qualified_name);
|
||||
if (dwarf->GetUniqueDWARFASTTypeMap().Find(const_qualified_name, die, Declaration(),
|
||||
byte_size_valid ? byte_size : -1,
|
||||
*unique_ast_entry_ap))
|
||||
{
|
||||
// We have already parsed this type or from another
|
||||
// compile unit. GCC loves to use the "one definition
|
||||
// rule" which can result in multiple definitions
|
||||
// of the same class over and over in each compile
|
||||
// unit.
|
||||
type_sp = unique_ast_entry_ap->m_type_sp;
|
||||
if (type_sp)
|
||||
{
|
||||
|
@ -477,6 +479,24 @@ DWARFASTParserClang::ParseTypeFromDWARF (const SymbolContext& sc,
|
|||
return type_sp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!handled)
|
||||
{
|
||||
if (dwarf->GetUniqueDWARFASTTypeMap().Find(type_name_const_str, die, decl,
|
||||
byte_size_valid ? byte_size : -1,
|
||||
*unique_ast_entry_ap))
|
||||
{
|
||||
type_sp = unique_ast_entry_ap->m_type_sp;
|
||||
if (type_sp)
|
||||
{
|
||||
dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
|
||||
return type_sp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(), DW_TAG_value_to_name(tag), type_name_cstr);
|
||||
|
||||
|
@ -1278,7 +1298,6 @@ DWARFASTParserClang::ParseTypeFromDWARF (const SymbolContext& sc,
|
|||
|
||||
Host::SetCrashDescription (NULL);
|
||||
|
||||
|
||||
ClangASTMetadata metadata;
|
||||
metadata.SetUserID(die.GetID());
|
||||
|
||||
|
@ -1526,15 +1545,8 @@ DWARFASTParserClang::ParseTypeFromDWARF (const SymbolContext& sc,
|
|||
|
||||
byte_size = clang_type.GetByteSize(nullptr);
|
||||
|
||||
type_sp.reset( new Type (die.GetID(),
|
||||
dwarf,
|
||||
type_name_const_str,
|
||||
byte_size,
|
||||
NULL,
|
||||
LLDB_INVALID_UID,
|
||||
Type::eEncodingIsUID,
|
||||
NULL,
|
||||
clang_type,
|
||||
type_sp.reset(new Type(die.GetID(), dwarf, type_name_const_str, byte_size, NULL,
|
||||
LLDB_INVALID_UID, Type::eEncodingIsUID, NULL, clang_type,
|
||||
Type::eResolveStateForward));
|
||||
}
|
||||
|
||||
|
@ -2081,7 +2093,7 @@ DWARFASTParserClang::CompleteTypeFromDWARF (const DWARFDIE &die,
|
|||
}
|
||||
|
||||
std::vector<DWARFDIE>
|
||||
DWARFASTParserClang::GetDIEForDeclContext (lldb_private::CompilerDeclContext decl_context)
|
||||
DWARFASTParserClang::GetDIEForDeclContext(lldb_private::CompilerDeclContext decl_context)
|
||||
{
|
||||
std::vector<DWARFDIE> result;
|
||||
for (auto it = m_decl_ctx_to_die.find((clang::DeclContext *)decl_context.GetOpaqueDeclContext()); it != m_decl_ctx_to_die.end(); it++)
|
||||
|
|
Loading…
Reference in New Issue