[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


================
@@ -81,21 +100,28 @@ llvm::Expected<Token> DILLexer::Lex(llvm::StringRef expr,
     return Token(Token::eof, "", (uint32_t)expr.size());
 
   uint32_t position = cur_pos - expr.begin();
+  std::optional<llvm::StringRef> maybe_number = IsNumber(expr, remainder);
+  if (maybe_number) {
+    std::string number = (*maybe_number).str();
+    return Token(Token::numeric_constant, number, position);
+  }
----------------
labath wrote:

```suggestion
  if (maybe_number)
    return Token(Token::numeric_constant, maybe_number->str(), position);
```

mainly because it avoids making a copy of the std::string object (without resorting to std::move)

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


More information about the lldb-commits mailing list