- DebugLocEntry(const MCSymbol *B, const MCSymbol *E, MachineLocation &L,
- const MDNode *V, const DwarfCompileUnit *U)
- : Begin(B), End(E), Loc(L), Variable(V), Unit(U) {
- Constants.Int = 0;
- EntryKind = E_Location;
- }
- DebugLocEntry(const MCSymbol *B, const MCSymbol *E, int64_t i,
- const MDNode *V, const DwarfCompileUnit *U)
- : Begin(B), End(E), Variable(V), Unit(U) {
- Constants.Int = i;
- EntryKind = E_Integer;
- }
- DebugLocEntry(const MCSymbol *B, const MCSymbol *E, const ConstantFP *FPtr,
- const MDNode *V, const DwarfCompileUnit *U)
- : Begin(B), End(E), Variable(V), Unit(U) {
- Constants.CFP = FPtr;
- EntryKind = E_ConstantFP;
- }
- DebugLocEntry(const MCSymbol *B, const MCSymbol *E, const ConstantInt *IPtr,
- const MDNode *V, const DwarfCompileUnit *U)
- : Begin(B), End(E), Variable(V), Unit(U) {
- Constants.CIP = IPtr;
- EntryKind = E_ConstantInt;
+
+ /// \brief If this and Next are describing different pieces of the same
+ /// variable, merge them by appending Next's values to the current
+ /// list of values.
+ /// Return true if the merge was successful.
+ bool MergeValues(const DebugLocEntry &Next) {
+ if (Begin == Next.Begin) {
+ auto *Expr = cast_or_null<DIExpression>(Values[0].Expression);
+ auto *NextExpr = cast_or_null<DIExpression>(Next.Values[0].Expression);
+ if (Expr->isBitPiece() && NextExpr->isBitPiece()) {
+ addValues(Next.Values);
+ End = Next.End;
+ return true;
+ }
+ }
+ return false;