Skip to content

Commit 1b39ae4

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 901d210 commit 1b39ae4

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

llvm/include/llvm/IR/DebugInfoMetadata.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3142,6 +3142,25 @@ 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+
DIExpression::expr_op_iterator NewStart(Expr.begin());
3159+
DIExpression::expr_op_iterator NewEnd(Expr.end());
3160+
this->Start = NewStart;
3161+
this->End = NewEnd;
3162+
}
3163+
31453164
/// Determine whether there are any operations left in this expression.
31463165
operator bool() const { return Start != End; }
31473166

0 commit comments

Comments
 (0)