llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: Ilia Kuklin (kuilpd) <details> <summary>Changes</summary> --- Full diff: https://github.com/llvm/llvm-project/pull/144557.diff 3 Files Affected: - (modified) lldb/source/ValueObject/DILParser.cpp (+9-2) - (modified) lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/TestFrameVarDILArraySubscript.py (+1-5) - (modified) lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/main.cpp (+1) ``````````diff diff --git a/lldb/source/ValueObject/DILParser.cpp b/lldb/source/ValueObject/DILParser.cpp index 32af0820acb98..146ef8154283e 100644 --- a/lldb/source/ValueObject/DILParser.cpp +++ b/lldb/source/ValueObject/DILParser.cpp @@ -348,8 +348,15 @@ void DILParser::BailOut(const std::string &error, uint32_t loc, // ? Integer constant ? // std::optional<int64_t> DILParser::ParseIntegerConstant() { - auto spelling = CurToken().GetSpelling(); - llvm::StringRef spelling_ref = spelling; + std::string number_spelling; + if (CurToken().GetKind() == Token::minus) { + // StringRef::getAsInteger<>() can parse negative numbers. + // Remove this once unary minus operator is added. + number_spelling = "-"; + m_dil_lexer.Advance(); + } + number_spelling.append(CurToken().GetSpelling()); + llvm::StringRef spelling_ref = number_spelling; int64_t raw_value; if (!spelling_ref.getAsInteger<int64_t>(0, raw_value)) { m_dil_lexer.Advance(); diff --git a/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/TestFrameVarDILArraySubscript.py b/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/TestFrameVarDILArraySubscript.py index c90e0eaa63638..c0ef29fab8597 100644 --- a/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/TestFrameVarDILArraySubscript.py +++ b/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/TestFrameVarDILArraySubscript.py @@ -60,11 +60,7 @@ def test_subscript(self): self.expect_var_path("*(&int_arr[1])", value="2") # Test for negative index. - self.expect( - "frame var 'int_arr[-1]'", - error=True, - substrs=["failed to parse integer constant"], - ) + self.expect_var_path("int_ptr_1[-1]", True, value="1") # Test for floating point index self.expect( diff --git a/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/main.cpp b/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/main.cpp index 485666ae46c20..a9a3612dfae5a 100644 --- a/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/main.cpp +++ b/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/main.cpp @@ -3,6 +3,7 @@ int main(int argc, char **argv) { int int_arr[] = {1, 2, 3}; int *int_ptr = int_arr; + int *int_ptr_1 = &int_arr[1]; int(&int_arr_ref)[3] = int_arr; void *p_void = (void *)int_arr; `````````` </details> https://github.com/llvm/llvm-project/pull/144557 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits