[Lldb-commits] [lldb] [LLDB] Add array subscription and integer parsing to DIL (PR #138551)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Wed May 14 04:50:59 PDT 2025


================
@@ -108,6 +110,26 @@ class UnaryOpNode : public ASTNode {
   ASTNodeUP m_operand;
 };
 
+class ArraySubscriptNode : public ASTNode {
+public:
+  ArraySubscriptNode(uint32_t location, ASTNodeUP base, llvm::APInt index)
+      : ASTNode(location, NodeKind::eArraySubscriptNode),
+        m_base(std::move(base)), m_index(std::move(index)) {}
+
+  llvm::Expected<lldb::ValueObjectSP> Accept(Visitor *v) const override;
+
+  ASTNode *GetBase() const { return m_base.get(); }
+  const llvm::APInt *GetIndex() const { return &m_index; }
----------------
labath wrote:

I think this should return a (const) reference to make it clear it can't be null.

(I know the same can be said about the GetBase, and I'd actually do that there as well, but it's less of a surprise there since the object is already stored as a pointer)

https://github.com/llvm/llvm-project/pull/138551


More information about the lldb-commits mailing list