Skip to content

Commit 2f186c4

Browse files
[NFC] Move DIExpressionCursor to DebugInfoMetadata.h
1 parent f8063ff commit 2f186c4

File tree

2 files changed

+61
-61
lines changed

2 files changed

+61
-61
lines changed

llvm/include/llvm/IR/DebugInfoMetadata.h

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3150,6 +3150,67 @@ template <> struct DenseMapInfo<DIExpression::FragmentInfo> {
31503150
static bool isEqual(const FragInfo &A, const FragInfo &B) { return A == B; }
31513151
};
31523152

3153+
/// Holds a DIExpression and keeps track of how many operands have been consumed
3154+
/// so far.
3155+
class DIExpressionCursor {
3156+
DIExpression::expr_op_iterator Start, End;
3157+
3158+
public:
3159+
DIExpressionCursor(const DIExpression *Expr) {
3160+
if (!Expr) {
3161+
assert(Start == End);
3162+
return;
3163+
}
3164+
Start = Expr->expr_op_begin();
3165+
End = Expr->expr_op_end();
3166+
}
3167+
3168+
DIExpressionCursor(ArrayRef<uint64_t> Expr)
3169+
: Start(Expr.begin()), End(Expr.end()) {}
3170+
3171+
DIExpressionCursor(const DIExpressionCursor &) = default;
3172+
3173+
/// Consume one operation.
3174+
std::optional<DIExpression::ExprOperand> take() {
3175+
if (Start == End)
3176+
return std::nullopt;
3177+
return *(Start++);
3178+
}
3179+
3180+
/// Consume N operations.
3181+
void consume(unsigned N) { std::advance(Start, N); }
3182+
3183+
/// Return the current operation.
3184+
std::optional<DIExpression::ExprOperand> peek() const {
3185+
if (Start == End)
3186+
return std::nullopt;
3187+
return *(Start);
3188+
}
3189+
3190+
/// Return the next operation.
3191+
std::optional<DIExpression::ExprOperand> peekNext() const {
3192+
if (Start == End)
3193+
return std::nullopt;
3194+
3195+
auto Next = Start.getNext();
3196+
if (Next == End)
3197+
return std::nullopt;
3198+
3199+
return *Next;
3200+
}
3201+
3202+
/// Determine whether there are any operations left in this expression.
3203+
operator bool() const { return Start != End; }
3204+
3205+
DIExpression::expr_op_iterator begin() const { return Start; }
3206+
DIExpression::expr_op_iterator end() const { return End; }
3207+
3208+
/// Retrieve the fragment information, if any.
3209+
std::optional<DIExpression::FragmentInfo> getFragmentInfo() const {
3210+
return DIExpression::getFragmentInfo(Start, End);
3211+
}
3212+
};
3213+
31533214
/// Global variables.
31543215
///
31553216
/// TODO: Remove DisplayName. It's always equal to Name.

llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -31,67 +31,6 @@ class DIELoc;
3131
class TargetRegisterInfo;
3232
class MachineLocation;
3333

34-
/// Holds a DIExpression and keeps track of how many operands have been consumed
35-
/// so far.
36-
class DIExpressionCursor {
37-
DIExpression::expr_op_iterator Start, End;
38-
39-
public:
40-
DIExpressionCursor(const DIExpression *Expr) {
41-
if (!Expr) {
42-
assert(Start == End);
43-
return;
44-
}
45-
Start = Expr->expr_op_begin();
46-
End = Expr->expr_op_end();
47-
}
48-
49-
DIExpressionCursor(ArrayRef<uint64_t> Expr)
50-
: Start(Expr.begin()), End(Expr.end()) {}
51-
52-
DIExpressionCursor(const DIExpressionCursor &) = default;
53-
54-
/// Consume one operation.
55-
std::optional<DIExpression::ExprOperand> take() {
56-
if (Start == End)
57-
return std::nullopt;
58-
return *(Start++);
59-
}
60-
61-
/// Consume N operations.
62-
void consume(unsigned N) { std::advance(Start, N); }
63-
64-
/// Return the current operation.
65-
std::optional<DIExpression::ExprOperand> peek() const {
66-
if (Start == End)
67-
return std::nullopt;
68-
return *(Start);
69-
}
70-
71-
/// Return the next operation.
72-
std::optional<DIExpression::ExprOperand> peekNext() const {
73-
if (Start == End)
74-
return std::nullopt;
75-
76-
auto Next = Start.getNext();
77-
if (Next == End)
78-
return std::nullopt;
79-
80-
return *Next;
81-
}
82-
83-
/// Determine whether there are any operations left in this expression.
84-
operator bool() const { return Start != End; }
85-
86-
DIExpression::expr_op_iterator begin() const { return Start; }
87-
DIExpression::expr_op_iterator end() const { return End; }
88-
89-
/// Retrieve the fragment information, if any.
90-
std::optional<DIExpression::FragmentInfo> getFragmentInfo() const {
91-
return DIExpression::getFragmentInfo(Start, End);
92-
}
93-
};
94-
9534
/// Base class containing the logic for constructing DWARF expressions
9635
/// independently of whether they are emitted into a DIE or into a .debug_loc
9736
/// entry.

0 commit comments

Comments
 (0)