Skip to content

Commit d105b0f

Browse files
[NFC] Move DIExpressionCursor to DebugInfoMetadata.h
1 parent 839a8fe commit d105b0f

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

3096+
/// Holds a DIExpression and keeps track of how many operands have been consumed
3097+
/// so far.
3098+
class DIExpressionCursor {
3099+
DIExpression::expr_op_iterator Start, End;
3100+
3101+
public:
3102+
DIExpressionCursor(const DIExpression *Expr) {
3103+
if (!Expr) {
3104+
assert(Start == End);
3105+
return;
3106+
}
3107+
Start = Expr->expr_op_begin();
3108+
End = Expr->expr_op_end();
3109+
}
3110+
3111+
DIExpressionCursor(ArrayRef<uint64_t> Expr)
3112+
: Start(Expr.begin()), End(Expr.end()) {}
3113+
3114+
DIExpressionCursor(const DIExpressionCursor &) = default;
3115+
3116+
/// Consume one operation.
3117+
std::optional<DIExpression::ExprOperand> take() {
3118+
if (Start == End)
3119+
return std::nullopt;
3120+
return *(Start++);
3121+
}
3122+
3123+
/// Consume N operations.
3124+
void consume(unsigned N) { std::advance(Start, N); }
3125+
3126+
/// Return the current operation.
3127+
std::optional<DIExpression::ExprOperand> peek() const {
3128+
if (Start == End)
3129+
return std::nullopt;
3130+
return *(Start);
3131+
}
3132+
3133+
/// Return the next operation.
3134+
std::optional<DIExpression::ExprOperand> peekNext() const {
3135+
if (Start == End)
3136+
return std::nullopt;
3137+
3138+
auto Next = Start.getNext();
3139+
if (Next == End)
3140+
return std::nullopt;
3141+
3142+
return *Next;
3143+
}
3144+
3145+
/// Determine whether there are any operations left in this expression.
3146+
operator bool() const { return Start != End; }
3147+
3148+
DIExpression::expr_op_iterator begin() const { return Start; }
3149+
DIExpression::expr_op_iterator end() const { return End; }
3150+
3151+
/// Retrieve the fragment information, if any.
3152+
std::optional<DIExpression::FragmentInfo> getFragmentInfo() const {
3153+
return DIExpression::getFragmentInfo(Start, End);
3154+
}
3155+
};
3156+
30963157
/// Global variables.
30973158
///
30983159
/// 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)