/// addChild - Add a child to the DIE.
///
void addChild(DIE *Child) {
- if (Child->getParent()) {
- assert (Child->getParent() == this && "Unexpected DIE Parent!");
- return;
- }
+ assert(!Child->getParent());
Abbrev.setChildrenFlag(dwarf::DW_CHILDREN_yes);
Children.push_back(Child);
Child->Parent = this;
/// addToContextOwner - Add Die into the list of its context owner's children.
void CompileUnit::addToContextOwner(DIE *Die, DIDescriptor Context) {
- if (DIE *ContextDIE = getOrCreateContextDIE(Context))
+ assert(!Die->getParent());
+ if (DIE *ContextDIE = getOrCreateContextDIE(Context)) {
+ if (Die->getParent()) {
+ // While creating the context, if this is a type member, we will have
+ // added the child to the context already.
+ assert(Die->getParent() == ContextDIE);
+ return;
+ }
ContextDIE->addChild(Die);
- else
+ } else
addDie(Die);
}
ElemDie = createStaticMemberDIE(DDTy);
else
ElemDie = createMemberDIE(DDTy);
+ Buffer.addChild(ElemDie);
} else if (Element.isObjCProperty()) {
DIObjCProperty Property(Element);
ElemDie = new DIE(Property.getTag());
Entry = createDIEEntry(ElemDie);
insertDIEEntry(Element, Entry);
}
+ Buffer.addChild(ElemDie);
} else
continue;
- Buffer.addChild(ElemDie);
}
if (CTy.isAppleBlockExtension())
if (DIDescriptor(ContainingType).isCompositeType())
addDIEEntry(&Buffer, dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4,
getOrCreateTypeDIE(DIType(ContainingType)));
- else
- addToContextOwner(&Buffer, DD->resolve(CTy.getContext()));
if (CTy.isObjcClassComplete())
addFlag(&Buffer, dwarf::DW_AT_APPLE_objc_complete_type);
DIE *SubprogramDie = TheCU->getOrCreateSubprogramDIE(SP);
- // Add to map.
- TheCU->insertDIE(N, SubprogramDie);
-
- // Add to context owner.
- TheCU->addToContextOwner(SubprogramDie, SP.getContext());
-
// Expose as a global name.
TheCU->addGlobalName(SP.getName(), SubprogramDie);
}