Check in getOrCreateSubprogramDIE if a declaration exists and if so output

it first.

This is a more general fix to pr11300.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144324 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2011-11-10 22:34:29 +00:00
parent 950dba04e0
commit 01b55b4a80
3 changed files with 55 additions and 13 deletions

View File

@@ -934,6 +934,12 @@ DIE *CompileUnit::getOrCreateSubprogramDIE(DISubprogram SP) {
if (SPDie)
return SPDie;
DISubprogram SPDecl = SP.getFunctionDeclaration();
DIE *DeclDie = NULL;
if (SPDecl.isSubprogram()) {
DeclDie = getOrCreateSubprogramDIE(SPDecl);
}
SPDie = new DIE(dwarf::DW_TAG_subprogram);
// DW_TAG_inlined_subroutine may refer to this DIE.
@@ -952,8 +958,13 @@ DIE *CompileUnit::getOrCreateSubprogramDIE(DISubprogram SP) {
// If this DIE is going to refer declaration info using AT_specification
// then there is no need to add other attributes.
if (SP.getFunctionDeclaration().isSubprogram())
if (DeclDie) {
// Refer function declaration directly.
addDIEEntry(SPDie, dwarf::DW_AT_specification, dwarf::DW_FORM_ref4,
DeclDie);
return SPDie;
}
// Constructors and operators for anonymous aggregates do not have names.
if (!SP.getName().empty())

View File

@@ -598,20 +598,8 @@ void DwarfDebug::constructSubprogramDIE(CompileUnit *TheCU,
// class type.
return;
DISubprogram SPDecl = SP.getFunctionDeclaration();
DIE *DeclDie = NULL;
if (SPDecl.isSubprogram()) {
DeclDie = TheCU->getOrCreateSubprogramDIE(SPDecl);
}
DIE *SubprogramDie = TheCU->getOrCreateSubprogramDIE(SP);
if (DeclDie) {
// Refer function declaration directly.
TheCU->addDIEEntry(SubprogramDie, dwarf::DW_AT_specification,
dwarf::DW_FORM_ref4, DeclDie);
}
// Add to map.
TheCU->insertDIE(N, SubprogramDie);