Skip to content

Commit d16393b

Browse files
[NFC] Move DIExpressionCursor to DebugInfoMetadata.h
1 parent 5070c1e commit d16393b

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

3076+
/// Holds a DIExpression and keeps track of how many operands have been consumed
3077+
/// so far.
3078+
class DIExpressionCursor {
3079+
DIExpression::expr_op_iterator Start, End;
3080+
3081+
public:
3082+
DIExpressionCursor(const DIExpression *Expr) {
3083+
if (!Expr) {
3084+
assert(Start == End);
3085+
return;
3086+
}
3087+
Start = Expr->expr_op_begin();
3088+
End = Expr->expr_op_end();
3089+
}
3090+
3091+
DIExpressionCursor(ArrayRef<uint64_t> Expr)
3092+
: Start(Expr.begin()), End(Expr.end()) {}
3093+
3094+
DIExpressionCursor(const DIExpressionCursor &) = default;
3095+
3096+
/// Consume one operation.
3097+
std::optional<DIExpression::ExprOperand> take() {
3098+
if (Start == End)
3099+
return std::nullopt;
3100+
return *(Start++);
3101+
}
3102+
3103+
/// Consume N operations.
3104+
void consume(unsigned N) { std::advance(Start, N); }
3105+
3106+
/// Return the current operation.
3107+
std::optional<DIExpression::ExprOperand> peek() const {
3108+
if (Start == End)
3109+
return std::nullopt;
3110+
return *(Start);
3111+
}
3112+
3113+
/// Return the next operation.
3114+
std::optional<DIExpression::ExprOperand> peekNext() const {
3115+
if (Start == End)
3116+
return std::nullopt;
3117+
3118+
auto Next = Start.getNext();
3119+
if (Next == End)
3120+
return std::nullopt;
3121+
3122+
return *Next;
3123+
}
3124+
3125+
/// Determine whether there are any operations left in this expression.
3126+
operator bool() const { return Start != End; }
3127+
3128+
DIExpression::expr_op_iterator begin() const { return Start; }
3129+
DIExpression::expr_op_iterator end() const { return End; }
3130+
3131+
/// Retrieve the fragment information, if any.
3132+
std::optional<DIExpression::FragmentInfo> getFragmentInfo() const {
3133+
return DIExpression::getFragmentInfo(Start, End);
3134+
}
3135+
};
3136+
30763137
/// Global variables.
30773138
///
30783139
/// 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)