Fix it so that we only grab the typedef from the module DWARF file if the type that is typedef'ed is a declaration. This fixes the following bugs:
<rdar://problem/26870890> [PR28156] TestWithModuleDebugging.py: failing on macOS https://llvm.org/bugs/show_bug.cgi?id=27412 https://llvm.org/bugs/show_bug.cgi?id=28156 llvm-svn: 274809
This commit is contained in:
parent
f731d0afed
commit
87c550324c
|
@ -275,30 +275,6 @@ DWARFASTParserClang::ParseTypeFromDWARF (const SymbolContext& sc,
|
|||
switch (tag)
|
||||
{
|
||||
case DW_TAG_typedef:
|
||||
// Try to parse a typedef from the DWO file first as modules
|
||||
// can contain typedef'ed structures that have no names like:
|
||||
//
|
||||
// typedef struct { int a; } Foo;
|
||||
//
|
||||
// In this case we will have a structure with no name and a
|
||||
// typedef named "Foo" that points to this unnamed structure.
|
||||
// The name in the typedef is the only identifier for the struct,
|
||||
// so always try to get typedefs from DWO files if possible.
|
||||
//
|
||||
// The type_sp returned will be empty if the typedef doesn't exist
|
||||
// in a DWO file, so it is cheap to call this function just to check.
|
||||
//
|
||||
// If we don't do this we end up creating a TypeSP that says this
|
||||
// is a typedef to type 0x123 (the DW_AT_type value would be 0x123
|
||||
// in the DW_TAG_typedef), and this is the unnamed structure type.
|
||||
// We will have a hard time tracking down an unnammed structure
|
||||
// type in the module DWO file, so we make sure we don't get into
|
||||
// this situation by always resolving typedefs from the DWO file.
|
||||
type_sp = ParseTypeFromDWO(die, log);
|
||||
if (type_sp)
|
||||
return type_sp;
|
||||
|
||||
LLVM_FALLTHROUGH;
|
||||
case DW_TAG_base_type:
|
||||
case DW_TAG_pointer_type:
|
||||
case DW_TAG_reference_type:
|
||||
|
@ -352,6 +328,42 @@ DWARFASTParserClang::ParseTypeFromDWARF (const SymbolContext& sc,
|
|||
}
|
||||
}
|
||||
|
||||
if (tag == DW_TAG_typedef)
|
||||
{
|
||||
// Try to parse a typedef from the DWO file first as modules
|
||||
// can contain typedef'ed structures that have no names like:
|
||||
//
|
||||
// typedef struct { int a; } Foo;
|
||||
//
|
||||
// In this case we will have a structure with no name and a
|
||||
// typedef named "Foo" that points to this unnamed structure.
|
||||
// The name in the typedef is the only identifier for the struct,
|
||||
// so always try to get typedefs from DWO files if possible.
|
||||
//
|
||||
// The type_sp returned will be empty if the typedef doesn't exist
|
||||
// in a DWO file, so it is cheap to call this function just to check.
|
||||
//
|
||||
// If we don't do this we end up creating a TypeSP that says this
|
||||
// is a typedef to type 0x123 (the DW_AT_type value would be 0x123
|
||||
// in the DW_TAG_typedef), and this is the unnamed structure type.
|
||||
// We will have a hard time tracking down an unnammed structure
|
||||
// type in the module DWO file, so we make sure we don't get into
|
||||
// this situation by always resolving typedefs from the DWO file.
|
||||
const DWARFDIE encoding_die = dwarf->GetDIE(DIERef(encoding_uid));
|
||||
|
||||
// First make sure that the die that this is typedef'ed to _is_
|
||||
// just a declaration (DW_AT_declaration == 1), not a full definition
|
||||
// since template types can't be represented in modules since only
|
||||
// concrete instances of templates are ever emitted and modules
|
||||
// won't contain those
|
||||
if (encoding_die && encoding_die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0) == 1)
|
||||
{
|
||||
type_sp = ParseTypeFromDWO(die, log);
|
||||
if (type_sp)
|
||||
return type_sp;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\") type => 0x%8.8lx\n", die.GetID(), DW_TAG_value_to_name(tag), type_name_cstr, encoding_uid.Reference());
|
||||
|
||||
switch (tag)
|
||||
|
|
Loading…
Reference in New Issue