================
@@ -64,6 +64,71 @@ enum LocationDescriptionKind {
/* Composite*/
};
+/// Keeps the location description kind associated with each eagerly
+/// materialized value on the DWARF expression stack.
+class EvaluationStack {
+public:
+ bool empty() const { return m_values.empty(); }
+ size_t size() const { return m_values.size(); }
+
+ Value &back() { return m_values.back(); }
+ const Value &back() const { return m_values.back(); }
+
+ Value &operator[](size_t index) { return m_values[index]; }
+ const Value &operator[](size_t index) const { return m_values[index]; }
+
+ void push_back(Value value, LocationDescriptionKind loc_desc_kind = Memory) {
+ m_values.push_back(std::move(value));
+ m_loc_desc_kinds.push_back(loc_desc_kind);
+ }
+
+ void PushCopy(size_t index) {
+ push_back(m_values[index], m_loc_desc_kinds[index]);
+ }
+
+ void pop_back() {
+ m_values.pop_back();
+ m_loc_desc_kinds.pop_back();
+ }
+
+ LocationDescriptionKind GetLocationDescriptionKind() const {
+ return m_loc_desc_kinds.back();
+ }
+
+ void SetLocationDescriptionKind(LocationDescriptionKind loc_desc_kind) {
+ m_loc_desc_kinds.back() = loc_desc_kind;
+ }
+
+ void SwapTopTwo() {
+ const size_t last = size() - 1;
+ std::swap(m_values[last], m_values[last - 1]);
+ std::swap(m_loc_desc_kinds[last], m_loc_desc_kinds[last - 1]);
+ }
+
+ void RotateTopThree() {
----------------
MrEven132 wrote:
It now returns `false` when fewer than three entries exist, and the evaluator
checks that result. Empty, one-entry, and two-entry stacks are covered by unit
tests.
https://github.com/llvm/llvm-project/pull/219372
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits