Skip to content

Commit 6bb96a0

Browse files
Add functions peekNextN(unsigned) and assignNewExpr(ArrayRef<uint64_t>) to DIExpressionCursor
This commit adds two functions to the DIExpressionCursor class. peekNextN(unsigned) works like peekNext, but lets you peek the next Nth element assignNewExpr(ArrayRef<uint64_t>) lets you assign a new expression to the same DIExpressionCursor object
1 parent a59ae42 commit 6bb96a0

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

llvm/include/llvm/IR/DebugInfoMetadata.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3199,6 +3199,23 @@ class DIExpressionCursor {
31993199
return *Next;
32003200
}
32013201

3202+
std::optional<DIExpression::ExprOperand> peekNextN(unsigned N) const {
3203+
if (Start == End)
3204+
return std::nullopt;
3205+
DIExpression::expr_op_iterator Nth = Start;
3206+
for (unsigned I = 0; I < N; I++) {
3207+
Nth = Nth.getNext();
3208+
if (Nth == End)
3209+
return std::nullopt;
3210+
}
3211+
return *Nth;
3212+
}
3213+
3214+
void assignNewExpr(ArrayRef<uint64_t> Expr) {
3215+
this->Start = DIExpression::expr_op_iterator(Expr.begin());
3216+
this->End = DIExpression::expr_op_iterator(Expr.end());
3217+
}
3218+
32023219
/// Determine whether there are any operations left in this expression.
32033220
operator bool() const { return Start != End; }
32043221

0 commit comments

Comments
 (0)