From 9a31fb66730cff57a12407fab67aca3f8356c08c Mon Sep 17 00:00:00 2001 From: Itamar Date: Sat, 3 Jul 2021 11:34:18 +0300 Subject: [PATCH] LibCpp: Fix positional information of Pointer types --- Userland/Libraries/LibCpp/Parser.cpp | 2 +- Userland/Libraries/LibCpp/Tests/strace.ast | 12 ++++++------ Userland/Libraries/LibCpp/Tests/struct.ast | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Userland/Libraries/LibCpp/Parser.cpp b/Userland/Libraries/LibCpp/Parser.cpp index 92fa07e02a..7b7d674801 100644 --- a/Userland/Libraries/LibCpp/Parser.cpp +++ b/Userland/Libraries/LibCpp/Parser.cpp @@ -1189,7 +1189,7 @@ NonnullRefPtr Parser::parse_type(ASTNode& parent) while (!eof() && peek().type() == Token::Type::Asterisk) { type->set_end(position()); auto asterisk = consume(); - auto ptr = create_ast_node(parent, asterisk.start(), asterisk.end()); + auto ptr = create_ast_node(parent, type->start(), asterisk.end()); type->set_parent(*ptr); ptr->m_pointee = type; ptr->set_end(position()); diff --git a/Userland/Libraries/LibCpp/Tests/strace.ast b/Userland/Libraries/LibCpp/Tests/strace.ast index f4ce346cb1..b01cb9e790 100644 --- a/Userland/Libraries/LibCpp/Tests/strace.ast +++ b/Userland/Libraries/LibCpp/Tests/strace.ast @@ -67,10 +67,10 @@ TranslationUnit[0:0->144:0] argc NamedType[12:9->12:13] int - Parameter[12:24->12:29] + Parameter[12:19->12:29] argv - Pointer[12:24->12:26] - Pointer[12:23->12:24] + Pointer[12:19->12:26] + Pointer[12:19->12:24] NamedType[12:19->12:23] char ) @@ -103,7 +103,7 @@ TranslationUnit[0:0->144:0] Vector<[const] char*> child_argv VariableDeclaration[21:4->21:41] - Pointer[21:14->21:16] + Pointer[21:4->21:16] NamedType[21:4->21:14] [const] char output_filename @@ -382,8 +382,8 @@ TranslationUnit[0:0->144:0] CppCastExpression[66:48->66:85] const_cast < - Pointer[66:64->66:65] - Pointer[66:63->66:64] + Pointer[66:59->66:65] + Pointer[66:59->66:64] NamedType[66:59->66:63] char > diff --git a/Userland/Libraries/LibCpp/Tests/struct.ast b/Userland/Libraries/LibCpp/Tests/struct.ast index 29bd29e5db..a59e9c21e8 100644 --- a/Userland/Libraries/LibCpp/Tests/struct.ast +++ b/Userland/Libraries/LibCpp/Tests/struct.ast @@ -6,7 +6,7 @@ TranslationUnit[1:0->12:0] int x VariableDeclaration[4:4->5:0] - Pointer[4:12->4:14] + Pointer[4:4->4:14] NamedType[4:4->4:12] s next