return ScopeDIE;
}
+static std::unique_ptr<DIE> constructVariableDIE(DwarfCompileUnit &TheCU,
+ DbgVariable &DV,
+ const LexicalScope &Scope,
+ DIE *&ObjectPointer) {
+ AbstractOrInlined AOI = AOI_None;
+ if (Scope.isAbstractScope())
+ AOI = AOI_Abstract;
+ else if (Scope.getInlinedAt())
+ AOI = AOI_Inlined;
+ auto Var = TheCU.constructVariableDIE(DV, AOI);
+ if (DV.isObjectPointer())
+ ObjectPointer = Var.get();
+ return Var;
+}
+
DIE *DwarfDebug::createScopeChildrenDIE(
DwarfCompileUnit &TheCU, LexicalScope *Scope,
SmallVectorImpl<std::unique_ptr<DIE>> &Children) {
// Collect arguments for current function.
if (LScopes.isCurrentFunctionScope(Scope)) {
for (DbgVariable *ArgDV : CurrentFnArguments)
- if (ArgDV) {
+ if (ArgDV)
Children.push_back(
- TheCU.constructVariableDIE(*ArgDV, Scope->isAbstractScope()));
- if (ArgDV->isObjectPointer())
- ObjectPointer = Children.back().get();
- }
+ constructVariableDIE(TheCU, *ArgDV, *Scope, ObjectPointer));
// If this is a variadic function, add an unspecified parameter.
DISubprogram SP(Scope->getScopeNode());
}
// Collect lexical scope children first.
- for (DbgVariable *DV : ScopeVariables.lookup(Scope)) {
- Children.push_back(
- TheCU.constructVariableDIE(*DV, Scope->isAbstractScope()));
- if (DV->isObjectPointer())
- ObjectPointer = Children.back().get();
- }
+ for (DbgVariable *DV : ScopeVariables.lookup(Scope))
+ Children.push_back(constructVariableDIE(TheCU, *DV, *Scope, ObjectPointer));
+
for (LexicalScope *LS : Scope->getChildren())
if (std::unique_ptr<DIE> Nested = constructScopeDIE(TheCU, LS))
Children.push_back(std::move(Nested));
if (!DV.isVariable())
continue;
DbgVariable NewVar(DV, nullptr, this);
- SPDIE->addChild(SPCU->constructVariableDIE(NewVar, false));
+ SPDIE->addChild(SPCU->constructVariableDIE(NewVar));
}
}
}
/// constructVariableDIE - Construct a DIE for the given DbgVariable.
std::unique_ptr<DIE> DwarfUnit::constructVariableDIE(DbgVariable &DV,
- bool isScopeAbstract) {
- auto D = constructVariableDIEImpl(DV, isScopeAbstract);
+ AbstractOrInlined AbsIn) {
+ auto D = constructVariableDIEImpl(DV, AbsIn);
DV.setDIE(*D);
return D;
}
-std::unique_ptr<DIE> DwarfUnit::constructVariableDIEImpl(const DbgVariable &DV,
- bool isScopeAbstract) {
+std::unique_ptr<DIE>
+DwarfUnit::constructVariableDIEImpl(const DbgVariable &DV,
+ AbstractOrInlined AbsIn) {
StringRef Name = DV.getName();
// Define variable debug information entry.
addType(*VariableDie, DV.getType());
}
- if (DV.isArtificial())
+ if (AbsIn != AOI_Inlined && DV.isArtificial())
addFlag(*VariableDie, dwarf::DW_AT_artificial);
- if (isScopeAbstract)
+ if (AbsIn == AOI_Abstract)
return VariableDie;
// Add variable address.
void addRange(RangeSpan Range) { Ranges.push_back(Range); }
};
+enum AbstractOrInlined { AOI_None, AOI_Inlined, AOI_Abstract };
+
//===----------------------------------------------------------------------===//
/// Unit - This dwarf writer support class manages information associated
/// with a source file.
/// constructVariableDIE - Construct a DIE for the given DbgVariable.
std::unique_ptr<DIE> constructVariableDIE(DbgVariable &DV,
- bool isScopeAbstract);
+ AbstractOrInlined AbsIn = AOI_None);
/// constructSubprogramArguments - Construct function argument DIEs.
DIE *constructSubprogramArguments(DIE &Buffer, DIArray Args);
/// \brief Construct a DIE for the given DbgVariable without initializing the
/// DbgVariable's DIE reference.
std::unique_ptr<DIE> constructVariableDIEImpl(const DbgVariable &DV,
- bool isScopeAbstract);
+ AbstractOrInlined AbsIn);
/// constructTypeDIE - Construct basic type die from DIBasicType.
void constructTypeDIE(DIE &Buffer, DIBasicType BTy);