Skip to content

Add functions peekNextN(unsigned) and assignNewExpr(ArrayRef<uint64_t>) to DIExpressionCursor #71717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions llvm/include/llvm/IR/DebugInfoMetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -3199,6 +3199,23 @@ class DIExpressionCursor {
return *Next;
}

std::optional<DIExpression::ExprOperand> peekNextN(unsigned N) const {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wants a doxygen comment. And maybe peekNextNth so as not to imply it returns the next N elements?

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<uint64_t> 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; }

Expand Down
Loading