Browse Source

LibCpp: Fix positional information of Pointer types

Itamar 4 years ago
parent
commit
9a31fb6673

+ 1 - 1
Userland/Libraries/LibCpp/Parser.cpp

@@ -1189,7 +1189,7 @@ NonnullRefPtr<Type> Parser::parse_type(ASTNode& parent)
     while (!eof() && peek().type() == Token::Type::Asterisk) {
         type->set_end(position());
         auto asterisk = consume();
-        auto ptr = create_ast_node<Pointer>(parent, asterisk.start(), asterisk.end());
+        auto ptr = create_ast_node<Pointer>(parent, type->start(), asterisk.end());
         type->set_parent(*ptr);
         ptr->m_pointee = type;
         ptr->set_end(position());

+ 6 - 6
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
                     >

+ 1 - 1
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