AsmPrinter: Take range in DwarfExpression::AddExpression(), NFC

Previously `DwarfExpression::AddExpression()` relied on
default-constructing the end iterators for `DIExpression` -- once the
operands are represented explicitly via `MDExpression` (instead of via
the strange `StringRef` navigator in `DIHeaderIterator`) this won't
work.  Explicitly take an iterator for the end of the range.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229572 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith 2015-02-17 22:30:56 +00:00
parent cbc2ca5ec9
commit 4c9121d5d9
4 changed files with 11 additions and 6 deletions

View File

@ -527,8 +527,11 @@ DwarfCompileUnit::constructVariableDIEImpl(const DbgVariable &DV,
const TargetFrameLowering *TFI =
Asm->TM.getSubtargetImpl()->getFrameLowering();
int Offset = TFI->getFrameIndexReference(*Asm->MF, FI, FrameReg);
assert(Expr != DV.getExpression().end() &&
"Wrong number of expressions");
DwarfExpr.AddMachineRegIndirect(FrameReg, Offset);
DwarfExpr.AddExpression(*(Expr++));
DwarfExpr.AddExpression(Expr->begin(), Expr->end());
++Expr;
}
addBlock(*VariableDie, dwarf::DW_AT_location, Loc);
@ -780,7 +783,7 @@ void DwarfCompileUnit::addComplexAddress(const DbgVariable &DV, DIE &Die,
ValidReg = DwarfExpr.AddMachineRegIndirect(Location.getReg(),
Location.getOffset());
if (ValidReg)
DwarfExpr.AddExpression(Expr);
DwarfExpr.AddExpression(Expr.begin(), Expr.end());
} else
ValidReg = DwarfExpr.AddMachineRegExpression(Expr, Location.getReg());

View File

@ -1725,7 +1725,7 @@ void DwarfDebug::emitDebugLocValue(ByteStreamer &Streamer,
// Complex address entry.
if (Loc.getOffset()) {
DwarfExpr.AddMachineRegIndirect(Loc.getReg(), Loc.getOffset());
DwarfExpr.AddExpression(Expr, PieceOffsetInBits);
DwarfExpr.AddExpression(Expr.begin(), Expr.end(), PieceOffsetInBits);
} else
DwarfExpr.AddMachineRegExpression(Expr, Loc.getReg(),
PieceOffsetInBits);

View File

@ -240,13 +240,14 @@ bool DwarfExpression::AddMachineRegExpression(DIExpression Expr,
return false;
// Emit remaining elements of the expression.
AddExpression(I, PieceOffsetInBits);
AddExpression(I, Expr.end(), PieceOffsetInBits);
return true;
}
void DwarfExpression::AddExpression(DIExpression::iterator I,
DIExpression::iterator E,
unsigned PieceOffsetInBits) {
for (; I != DIExpression::iterator(); ++I) {
for (; I != E; ++I) {
switch (*I) {
case dwarf::DW_OP_bit_piece: {
unsigned OffsetInBits = I->getArg(1);

View File

@ -96,7 +96,8 @@ public:
/// Emit a the operations remaining the DIExpressionIterator I.
/// \param PieceOffsetInBits If this is one piece out of a fragmented
/// location, this is the offset of the piece inside the entire variable.
void AddExpression(DIExpression::iterator I, unsigned PieceOffsetInBits = 0);
void AddExpression(DIExpression::iterator I, DIExpression::iterator E,
unsigned PieceOffsetInBits = 0);
};
/// DwarfExpression implementation for .debug_loc entries.