diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h index a1c554677f8bf..555bd623ad9ef 100644 --- a/llvm/include/llvm/IR/DebugInfoMetadata.h +++ b/llvm/include/llvm/IR/DebugInfoMetadata.h @@ -3199,6 +3199,23 @@ class DIExpressionCursor { return *Next; } + std::optional peekNextN(unsigned N) const { + if (Start == End) + return std::nullopt; + DIExpression::expr_op_iterator Nth = Start; + for (unsigned I = 0; I < N; I++) { + Nth = Nth.getNext(); + if (Nth == End) + return std::nullopt; + } + return *Nth; + } + + void assignNewExpr(ArrayRef Expr) { + this->Start = DIExpression::expr_op_iterator(Expr.begin()); + this->End = DIExpression::expr_op_iterator(Expr.end()); + } + /// Determine whether there are any operations left in this expression. operator bool() const { return Start != End; }