CTF AST: tmp_head list fixes
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 21 Feb 2011 16:38:25 +0000 (11:38 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 21 Feb 2011 16:38:25 +0000 (11:38 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
formats/ctf/metadata/ctf-parser.y
formats/ctf/metadata/ctf-test.txt
formats/ctf/metadata/ctf-visitor-xml.c

index 6706e3dcbff0df3fa341002ce9306d76d1640792..67180f6e4385bc5d44faa1e780098c85a1f12166 100644 (file)
@@ -194,6 +194,7 @@ static struct ctf_node *make_node(struct ctf_scanner *scanner,
        node->type = type;
        CDS_INIT_LIST_HEAD(&node->tmp_head);
        cds_list_add(&node->gc, &ast->allocated_nodes);
        node->type = type;
        CDS_INIT_LIST_HEAD(&node->tmp_head);
        cds_list_add(&node->gc, &ast->allocated_nodes);
+       cds_list_add(&node->siblings, &node->tmp_head);
 
        switch (type) {
        case NODE_ROOT:
 
        switch (type) {
        case NODE_ROOT:
@@ -906,21 +907,18 @@ postfix_expression:
                        $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
                        $$->u.unary_expression.type = UNARY_STRING;
                        $$->u.unary_expression.u.string = yylval.gs->s;
                        $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
                        $$->u.unary_expression.type = UNARY_STRING;
                        $$->u.unary_expression.u.string = yylval.gs->s;
-                       cds_list_add(&($$)->siblings, &($$)->tmp_head);
                }
        |       ID_TYPE
                {
                        $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
                        $$->u.unary_expression.type = UNARY_STRING;
                        $$->u.unary_expression.u.string = yylval.gs->s;
                }
        |       ID_TYPE
                {
                        $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
                        $$->u.unary_expression.type = UNARY_STRING;
                        $$->u.unary_expression.u.string = yylval.gs->s;
-                       cds_list_add(&($$)->siblings, &($$)->tmp_head);
                }
        |       keywords
                {
                        $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
                        $$->u.unary_expression.type = UNARY_STRING;
                        $$->u.unary_expression.u.string = yylval.gs->s;
                }
        |       keywords
                {
                        $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
                        $$->u.unary_expression.type = UNARY_STRING;
                        $$->u.unary_expression.u.string = yylval.gs->s;
-                       cds_list_add(&($$)->siblings, &($$)->tmp_head);
                }
 
        |       DECIMAL_CONSTANT
                }
 
        |       DECIMAL_CONSTANT
@@ -929,7 +927,6 @@ postfix_expression:
                        $$->u.unary_expression.type = UNARY_UNSIGNED_CONSTANT;
                        sscanf(yylval.gs->s, "%llu",
                               &$$->u.unary_expression.u.unsigned_constant);
                        $$->u.unary_expression.type = UNARY_UNSIGNED_CONSTANT;
                        sscanf(yylval.gs->s, "%llu",
                               &$$->u.unary_expression.u.unsigned_constant);
-                       cds_list_add(&($$)->siblings, &($$)->tmp_head);
                }
        |       OCTAL_CONSTANT
                {
                }
        |       OCTAL_CONSTANT
                {
@@ -937,7 +934,6 @@ postfix_expression:
                        $$->u.unary_expression.type = UNARY_UNSIGNED_CONSTANT;
                        sscanf(yylval.gs->s, "0%llo",
                               &$$->u.unary_expression.u.unsigned_constant);
                        $$->u.unary_expression.type = UNARY_UNSIGNED_CONSTANT;
                        sscanf(yylval.gs->s, "0%llo",
                               &$$->u.unary_expression.u.unsigned_constant);
-                       cds_list_add(&($$)->siblings, &($$)->tmp_head);
                }
        |       HEXADECIMAL_CONSTANT
                {
                }
        |       HEXADECIMAL_CONSTANT
                {
@@ -945,35 +941,30 @@ postfix_expression:
                        $$->u.unary_expression.type = UNARY_UNSIGNED_CONSTANT;
                        sscanf(yylval.gs->s, "0x%llx",
                               &$$->u.unary_expression.u.unsigned_constant);
                        $$->u.unary_expression.type = UNARY_UNSIGNED_CONSTANT;
                        sscanf(yylval.gs->s, "0x%llx",
                               &$$->u.unary_expression.u.unsigned_constant);
-                       cds_list_add(&($$)->siblings, &($$)->tmp_head);
                }
        |       STRING_LITERAL_START DQUOTE
                {
                        $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
                        $$->u.unary_expression.type = UNARY_STRING;
                        $$->u.unary_expression.u.string = "";
                }
        |       STRING_LITERAL_START DQUOTE
                {
                        $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
                        $$->u.unary_expression.type = UNARY_STRING;
                        $$->u.unary_expression.u.string = "";
-                       cds_list_add(&($$)->siblings, &($$)->tmp_head);
                }
        |       STRING_LITERAL_START s_char_sequence DQUOTE
                {
                        $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
                        $$->u.unary_expression.type = UNARY_STRING;
                        $$->u.unary_expression.u.string = $2->s;
                }
        |       STRING_LITERAL_START s_char_sequence DQUOTE
                {
                        $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
                        $$->u.unary_expression.type = UNARY_STRING;
                        $$->u.unary_expression.u.string = $2->s;
-                       cds_list_add(&($$)->siblings, &($$)->tmp_head);
                }
        |       CHARACTER_CONSTANT_START c_char_sequence SQUOTE
                {
                        $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
                        $$->u.unary_expression.type = UNARY_STRING;
                        $$->u.unary_expression.u.string = $2->s;
                }
        |       CHARACTER_CONSTANT_START c_char_sequence SQUOTE
                {
                        $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
                        $$->u.unary_expression.type = UNARY_STRING;
                        $$->u.unary_expression.u.string = $2->s;
-                       cds_list_add(&($$)->siblings, &($$)->tmp_head);
                }
        |       LPAREN unary_expression RPAREN
                {
                        $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
                        $$->u.unary_expression.type = UNARY_NESTED;
                        $$->u.unary_expression.u.nested_exp = $2;
                }
        |       LPAREN unary_expression RPAREN
                {
                        $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
                        $$->u.unary_expression.type = UNARY_NESTED;
                        $$->u.unary_expression.u.nested_exp = $2;
-                       cds_list_add(&($$)->siblings, &($$)->tmp_head);
                }
        |       postfix_expression LSBRAC unary_expression RSBRAC
                {
                }
        |       postfix_expression LSBRAC unary_expression RSBRAC
                {
@@ -1110,12 +1101,10 @@ event_declaration:
                event_declaration_begin event_declaration_end
                {
                        $$ = make_node(scanner, NODE_EVENT);
                event_declaration_begin event_declaration_end
                {
                        $$ = make_node(scanner, NODE_EVENT);
-                       cds_list_add(&($$)->siblings, &($$)->tmp_head);
                }
        |       event_declaration_begin ctf_assignment_expression_list event_declaration_end
                {
                        $$ = make_node(scanner, NODE_EVENT);
                }
        |       event_declaration_begin ctf_assignment_expression_list event_declaration_end
                {
                        $$ = make_node(scanner, NODE_EVENT);
-                       cds_list_add(&($$)->siblings, &($$)->tmp_head);
                        if (set_parent_node($2, $$))
                                reparent_error(scanner, "event_declaration");
                }
                        if (set_parent_node($2, $$))
                                reparent_error(scanner, "event_declaration");
                }
@@ -1136,12 +1125,10 @@ stream_declaration:
                stream_declaration_begin stream_declaration_end
                {
                        $$ = make_node(scanner, NODE_STREAM);
                stream_declaration_begin stream_declaration_end
                {
                        $$ = make_node(scanner, NODE_STREAM);
-                       cds_list_add(&($$)->siblings, &($$)->tmp_head);
                }
        |       stream_declaration_begin ctf_assignment_expression_list stream_declaration_end
                {
                        $$ = make_node(scanner, NODE_STREAM);
                }
        |       stream_declaration_begin ctf_assignment_expression_list stream_declaration_end
                {
                        $$ = make_node(scanner, NODE_STREAM);
-                       cds_list_add(&($$)->siblings, &($$)->tmp_head);
                        if (set_parent_node($2, $$))
                                reparent_error(scanner, "stream_declaration");
                }
                        if (set_parent_node($2, $$))
                                reparent_error(scanner, "stream_declaration");
                }
@@ -1162,12 +1149,10 @@ trace_declaration:
                trace_declaration_begin trace_declaration_end
                {
                        $$ = make_node(scanner, NODE_TRACE);
                trace_declaration_begin trace_declaration_end
                {
                        $$ = make_node(scanner, NODE_TRACE);
-                       cds_list_add(&($$)->siblings, &($$)->tmp_head);
                }
        |       trace_declaration_begin ctf_assignment_expression_list trace_declaration_end
                {
                        $$ = make_node(scanner, NODE_TRACE);
                }
        |       trace_declaration_begin ctf_assignment_expression_list trace_declaration_end
                {
                        $$ = make_node(scanner, NODE_TRACE);
-                       cds_list_add(&($$)->siblings, &($$)->tmp_head);
                        if (set_parent_node($2, $$))
                                reparent_error(scanner, "trace_declaration");
                }
                        if (set_parent_node($2, $$))
                                reparent_error(scanner, "trace_declaration");
                }
@@ -1188,13 +1173,9 @@ declaration_specifiers:
                {
                        $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
                        $$->u.type_specifier.type = TYPESPEC_CONST;
                {
                        $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
                        $$->u.type_specifier.type = TYPESPEC_CONST;
-                       cds_list_add(&($$)->siblings, &($$)->tmp_head);
                }
        |       type_specifier
                }
        |       type_specifier
-               {
-                       $$ = $1;
-                       cds_list_add(&($$)->siblings, &($$)->tmp_head);
-               }
+               {       $$ = $1;        }
        |       declaration_specifiers CONST
                {
                        struct ctf_node *node;
        |       declaration_specifiers CONST
                {
                        struct ctf_node *node;
@@ -1213,10 +1194,7 @@ declaration_specifiers:
 
 type_declarator_list:
                type_declarator
 
 type_declarator_list:
                type_declarator
-               {
-                       $$ = $1;
-                       cds_list_add(&($$)->siblings, &($$)->tmp_head);
-               }
+               {       $$ = $1;        }
        |       type_declarator_list COMMA type_declarator
                {
                        $$ = $1;
        |       type_declarator_list COMMA type_declarator
                {
                        $$ = $1;
@@ -1226,10 +1204,7 @@ type_declarator_list:
 
 abstract_type_declarator_list:
                abstract_type_declarator
 
 abstract_type_declarator_list:
                abstract_type_declarator
-               {
-                       $$ = $1;
-                       cds_list_add(&($$)->siblings, &($$)->tmp_head);
-               }
+               {       $$ = $1;        }
        |       abstract_type_declarator_list COMMA abstract_type_declarator
                {
                        $$ = $1;
        |       abstract_type_declarator_list COMMA abstract_type_declarator
                {
                        $$ = $1;
@@ -1675,13 +1650,9 @@ specifier_qualifier_list:
                {
                        $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
                        $$->u.type_specifier.type = TYPESPEC_CONST;
                {
                        $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
                        $$->u.type_specifier.type = TYPESPEC_CONST;
-                       cds_list_add(&($$)->siblings, &($$)->tmp_head);
                }
        |       type_specifier
                }
        |       type_specifier
-               {
-                       $$ = $1;
-                       cds_list_add(&($$)->siblings, &($$)->tmp_head);
-               }
+               {       $$ = $1;        }
        |       specifier_qualifier_list CONST
                {
                        struct ctf_node *node;
        |       specifier_qualifier_list CONST
                {
                        struct ctf_node *node;
@@ -1700,10 +1671,7 @@ specifier_qualifier_list:
 
 struct_or_variant_declarator_list:
                struct_or_variant_declarator
 
 struct_or_variant_declarator_list:
                struct_or_variant_declarator
-               {
-                       $$ = $1;
-                       cds_list_add(&($$)->siblings, &($$)->tmp_head);
-               }
+               {       $$ = $1;        }
        |       struct_or_variant_declarator_list COMMA struct_or_variant_declarator
                {
                        $$ = $1;
        |       struct_or_variant_declarator_list COMMA struct_or_variant_declarator
                {
                        $$ = $1;
@@ -1726,10 +1694,7 @@ struct_or_variant_declarator:
 
 enumerator_list:
                enumerator
 
 enumerator_list:
                enumerator
-               {
-                       $$ = $1;
-                       cds_list_add(&($$)->siblings, &($$)->tmp_head);
-               }
+               {       $$ = $1;        }
        |       enumerator_list COMMA enumerator
                {
                        $$ = $1;
        |       enumerator_list COMMA enumerator
                {
                        $$ = $1;
@@ -1797,10 +1762,7 @@ enumerator:
 
 abstract_declarator_list:
                abstract_declarator
 
 abstract_declarator_list:
                abstract_declarator
-               {
-                       $$ = $1;
-                       cds_list_add(&($$)->siblings, &($$)->tmp_head);
-               }
+               {       $$ = $1;        }
        |       abstract_declarator_list COMMA abstract_declarator
                {
                        $$ = $1;
        |       abstract_declarator_list COMMA abstract_declarator
                {
                        $$ = $1;
@@ -1968,20 +1930,17 @@ pointer:
                STAR
                {
                        $$ = make_node(scanner, NODE_POINTER);
                STAR
                {
                        $$ = make_node(scanner, NODE_POINTER);
-                       cds_list_add(&($$)->siblings, &($$)->tmp_head);
                }
        |       STAR pointer
                {
                        $$ = make_node(scanner, NODE_POINTER);
                        cds_list_splice(&($2)->tmp_head, &($$)->tmp_head);
                }
        |       STAR pointer
                {
                        $$ = make_node(scanner, NODE_POINTER);
                        cds_list_splice(&($2)->tmp_head, &($$)->tmp_head);
-                       cds_list_add(&($$)->siblings, &($$)->tmp_head);
                }
        |       STAR type_qualifier_list pointer
                {
                        $$ = make_node(scanner, NODE_POINTER);
                        $$->u.pointer.const_qualifier = 1;
                        cds_list_splice(&($3)->tmp_head, &($$)->tmp_head);
                }
        |       STAR type_qualifier_list pointer
                {
                        $$ = make_node(scanner, NODE_POINTER);
                        $$->u.pointer.const_qualifier = 1;
                        cds_list_splice(&($3)->tmp_head, &($$)->tmp_head);
-                       cds_list_add(&($$)->siblings, &($$)->tmp_head);
                }
        ;
 
                }
        ;
 
@@ -1995,10 +1954,7 @@ type_qualifier_list:
 
 ctf_assignment_expression_list:
                ctf_assignment_expression SEMICOLON
 
 ctf_assignment_expression_list:
                ctf_assignment_expression SEMICOLON
-               {
-                       $$ = $1;
-                       cds_list_add(&($$)->siblings, &($$)->tmp_head);
-               }
+               {       $$ = $1;        }
        |       ctf_assignment_expression_list ctf_assignment_expression SEMICOLON
                {
                        $$ = $1;
        |       ctf_assignment_expression_list ctf_assignment_expression SEMICOLON
                {
                        $$ = $1;
index 52fda7b85fd6359ef948262480d7fe6da51a369e..b051a79f627cd10f3e7f1953af700807b48d0a6a 100644 (file)
@@ -155,3 +155,5 @@ typedef int rootscopetest;
 
 event { a.b.c.d.e = f.g.h->i->j; };
 
 
 event { a.b.c.d.e = f.g.h->i->j; };
 
+typealias integer { size = 32; align = 32; signed = false; } : unsigned long long *;
+typealias integer { size = 32; align = 32; signed = false; } : unsigned const long [];
index 22829d9b47401ab1132cfcf0465fb113267bdce4..96d4ec5fc2fa15a347fbc689abb5fc54df190515 100644 (file)
@@ -192,10 +192,12 @@ int ctf_visitor_print_type_declarator(FILE *fd, int depth, struct ctf_node *node
 
        switch (node->u.type_declarator.type) {
        case TYPEDEC_ID:
 
        switch (node->u.type_declarator.type) {
        case TYPEDEC_ID:
-               print_tabs(fd, depth);
-               fprintf(fd, "<id \"");
-               fprintf(fd, "%s", node->u.type_declarator.u.id);
-               fprintf(fd, "\" />\n");
+               if (node->u.type_declarator.u.id) {
+                       print_tabs(fd, depth);
+                       fprintf(fd, "<id \"");
+                       fprintf(fd, "%s", node->u.type_declarator.u.id);
+                       fprintf(fd, "\" />\n");
+               }
                break;
        case TYPEDEC_NESTED:
                if (node->u.type_declarator.u.nested.type_declarator) {
                break;
        case TYPEDEC_NESTED:
                if (node->u.type_declarator.u.nested.type_declarator) {
This page took 0.02941 seconds and 4 git commands to generate.