[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
Fri May 16 00:12:07 PDT 2025


================
@@ -111,7 +111,42 @@ ASTNodeUP DILParser::ParseUnaryExpression() {
       llvm_unreachable("invalid token kind");
     }
   }
-  return ParsePrimaryExpression();
+  return ParsePostfixExpression();
+}
+
+// Parse a postfix_expression.
+//
+//  postfix_expression:
+//    primary_expression
+//    postfix_expression "[" integer_literal "]"
+//
+ASTNodeUP DILParser::ParsePostfixExpression() {
+  ASTNodeUP lhs = ParsePrimaryExpression();
+  while (CurToken().Is(Token::l_square)) {
+    uint32_t loc = CurToken().GetLocation();
+    Token token = CurToken();
+    switch (token.GetKind()) {
+    case Token::l_square: {
+      m_dil_lexer.Advance();
+      auto rhs = ParseIntegerConstant();
----------------
labath wrote:

LLVM generally has a very cautious stance towards auto: https://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable

In this case, the type of rhs is not obvious from the immediate, and for the correctness of the code, it is important to know whether the function returns `int`, `optional<int>`, `Expected<int>` or something else.

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


More information about the lldb-commits mailing list