Skip to content

Commit 8923f81

Browse files
[NFC] Move DIExpressionCursor to DebugInfoMetadata.h
1 parent 1f01c58 commit 8923f81

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
@@ -3145,6 +3145,67 @@ template <> struct DenseMapInfo<DIExpression::FragmentInfo> {
31453145
static bool isEqual(const FragInfo &A, const FragInfo &B) { return A == B; }
31463146
};
31473147

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