return !getLabelAfterInsn(Ranges.front().second);
}
-// Construct new DW_TAG_lexical_block for this scope and attach
-// DW_AT_low_pc/DW_AT_high_pc labels.
-std::unique_ptr<DIE>
-DwarfDebug::constructLexicalScopeDIE(DwarfCompileUnit &TheCU,
- LexicalScope *Scope) {
- if (isLexicalScopeDIENull(Scope))
- return nullptr;
-
- auto ScopeDIE = make_unique<DIE>(dwarf::DW_TAG_lexical_block);
- if (Scope->isAbstractScope())
- return ScopeDIE;
-
- TheCU.attachRangesOrLowHighPC(*ScopeDIE, Scope->getRanges());
-
- return ScopeDIE;
-}
-
-static std::unique_ptr<DIE> constructVariableDIE(DwarfCompileUnit &TheCU,
- DbgVariable &DV,
- const LexicalScope &Scope,
- DIE *&ObjectPointer) {
- auto Var = TheCU.constructVariableDIE(DV, Scope.isAbstractScope());
- if (DV.isObjectPointer())
- ObjectPointer = Var.get();
- return Var;
-}
-
-DIE *DwarfDebug::createScopeChildrenDIE(
- DwarfCompileUnit &TheCU, LexicalScope *Scope,
- SmallVectorImpl<std::unique_ptr<DIE>> &Children,
- unsigned *ChildScopeCount) {
- DIE *ObjectPointer = nullptr;
-
- for (DbgVariable *DV : ScopeVariables.lookup(Scope))
- Children.push_back(constructVariableDIE(TheCU, *DV, *Scope, ObjectPointer));
-
- unsigned ChildCountWithoutScopes = Children.size();
-
- for (LexicalScope *LS : Scope->getChildren())
- TheCU.constructScopeDIE(LS, Children);
-
- if (ChildScopeCount)
- *ChildScopeCount = Children.size() - ChildCountWithoutScopes;
-
- return ObjectPointer;
-}
-
DIE *DwarfDebug::createAndAddScopeChildren(DwarfCompileUnit &TheCU,
LexicalScope *Scope, DIE &ScopeDIE) {
// We create children when the scope DIE is not null.
SmallVector<std::unique_ptr<DIE>, 8> Children;
- DIE *ObjectPointer = createScopeChildrenDIE(TheCU, Scope, Children);
+ DIE *ObjectPointer = TheCU.createScopeChildrenDIE(Scope, Children);
// Add children
for (auto &I : Children)
for (DbgVariable *ArgDV : CurrentFnArguments)
if (ArgDV)
ScopeDIE.addChild(
- constructVariableDIE(TheCU, *ArgDV, *Scope, ObjectPointer));
+ TheCU.constructVariableDIE(*ArgDV, *Scope, ObjectPointer));
// If this is a variadic function, add an unspecified parameter.
DITypeArray FnArgs = Sub.getType().getTypeArray();
assert(ScopeVariables.empty());
assert(CurrentFnArguments.empty());
assert(DbgValues.empty());
+ // FIXME: This wouldn't be true in LTO with a -g (with inlining) CU followed
+ // by a -gmlt CU. Add a test and remove this assertion.
assert(AbstractVariables.empty());
LabelsBeforeInsn.clear();
LabelsAfterInsn.clear();