Skip to content

Commit 1f9b481

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 d105b0f commit 1f9b481

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
@@ -3142,6 +3142,23 @@ class DIExpressionCursor {
31423142
return *Next;
31433143
}
31443144

3145+
std::optional<DIExpression::ExprOperand> peekNextN(unsigned N) const {
3146+
if (Start == End)
3147+
return std::nullopt;
3148+
DIExpression::expr_op_iterator Nth = Start;
3149+
for (unsigned I = 0; I < N; I++) {
3150+
Nth = Nth.getNext();
3151+
if (Nth == End)
3152+
return std::nullopt;
3153+
}
3154+
return *Nth;
3155+
}
3156+
3157+
void assignNewExpr(ArrayRef<uint64_t> Expr) {
3158+
this->Start = DIExpression::expr_op_iterator(Expr.begin());
3159+
this->End = DIExpression::expr_op_iterator(Expr.end());
3160+
}
3161+
31453162
/// Determine whether there are any operations left in this expression.
31463163
operator bool() const { return Start != End; }
31473164

0 commit comments

Comments
 (0)