Emit DW_AT_object_pointer once, on the declaration, for each function.

This effectively reverts r164326, but adds some comments and
justification and ensures we /don't/ emit the DW_AT_object_pointer on
the (abstract and concrete) definitions. (while still preserving it on
standalone definitions involving ObjC Blocks)

This does increase the size of member function declarations from 7 to 11
bytes, unfortunately, but still seems like the Right Thing to do so that
callers that see only the declaration still have the information about
the object pointer. That said, I don't know what, if any, DWARF
consumers don't have a heuristic to guess this in the case of normal
C++ member functions - perhaps we can remove it entirely.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207705 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie
2014-04-30 21:29:41 +00:00
parent 289978069f
commit f345c4732c
6 changed files with 48 additions and 14 deletions

View File

@ -1164,7 +1164,8 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, DIDerivedType DTy) {
}
/// constructSubprogramArguments - Construct function argument DIEs.
void DwarfUnit::constructSubprogramArguments(DIE &Buffer, DIArray Args) {
DIE *DwarfUnit::constructSubprogramArguments(DIE &Buffer, DIArray Args) {
DIE *ObjectPointer = nullptr;
for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
DIDescriptor Ty = Args.getElement(i);
if (Ty.isUnspecifiedParameter()) {
@ -1175,8 +1176,11 @@ void DwarfUnit::constructSubprogramArguments(DIE &Buffer, DIArray Args) {
addType(Arg, DIType(Ty));
if (DIType(Ty).isArtificial())
addFlag(Arg, dwarf::DW_AT_artificial);
if (DIType(Ty).isObjectPointer())
ObjectPointer = &Arg;
}
}
return ObjectPointer;
}
/// constructTypeDIE - Construct type DIE from DICompositeType.
@ -1497,7 +1501,8 @@ DIE *DwarfUnit::getOrCreateSubprogramDIE(DISubprogram SP) {
// Add arguments. Do not add arguments for subprogram definition. They will
// be handled while processing variables.
constructSubprogramArguments(SPDie, Args);
if (DIE *ObjectPointer = constructSubprogramArguments(SPDie, Args))
addDIEEntry(SPDie, dwarf::DW_AT_object_pointer, *ObjectPointer);
}
if (SP.isArtificial())