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

Jeremy Morse via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 14 09:20:54 PST 2023


================
@@ -3122,6 +3122,25 @@ class DIExpressionCursor {
     return *Next;
   }
 
+  std::optional<DIExpression::ExprOperand> 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<uint64_t> Expr) {
+    DIExpression::expr_op_iterator NewStart(Expr.begin());
+    DIExpression::expr_op_iterator NewEnd(Expr.end());
----------------
jmorse wrote:

Can these not be directly assigned to `this->Start` and `this->End` instead of going through the intermediate variables?

https://github.com/llvm/llvm-project/pull/71717


More information about the llvm-commits mailing list