Skip to content

Commit d64f7e5

Browse files
committed
fix(extract): name an anonymous C typedef aggregate once
Main (DeusData#2458) named the anonymous struct/union/enum of `typedef struct { ... } Name;` in extract_class_def from the typedef's declarator. This branch's extract_c_typedef already emits that aggregate as Name from the type_definition, so on the merged tree Name was emitted twice under one label: its members twice and a false variants entry. extract_c_typedef stays the one place that names it; the extract_class_def case is removed. Both typedef test sets pass on the result: DeusData#2458's extract_c_anonymous_typedef_aggregate_is_named_by_its_typedef and member-access tests, and this branch's C1 typedef/variant tests (extraction, pipeline, registry, graph_buffer, store_search, mcp: 1,336 passed, 4 skipped). Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent d050fca commit d64f7e5

1 file changed

Lines changed: 3 additions & 21 deletions

File tree

‎internal/cbm/extract_defs.c‎

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7379,27 +7379,9 @@ static void extract_class_def(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec
73797379
}
73807380
break;
73817381
}
7382-
case CBM_LANG_C:
7383-
case CBM_LANG_CPP: { // `typedef struct { … } Name;`: the aggregate is
7384-
// anonymous and the typedef's declarator names it.
7385-
// A pointer/array/function declarator names another
7386-
// type, not the aggregate, so only a plain
7387-
// type_identifier counts.
7388-
if (strcmp(kind, "struct_specifier") != 0 && strcmp(kind, "union_specifier") != 0 &&
7389-
strcmp(kind, "enum_specifier") != 0) {
7390-
break;
7391-
}
7392-
TSNode parent = ts_node_parent(node);
7393-
if (ts_node_is_null(parent) || strcmp(ts_node_type(parent), "type_definition") != 0) {
7394-
break;
7395-
}
7396-
TSNode declarator = ts_node_child_by_field_name(parent, TS_FIELD("declarator"));
7397-
if (!ts_node_is_null(declarator) &&
7398-
strcmp(ts_node_type(declarator), "type_identifier") == 0) {
7399-
name_node = declarator;
7400-
}
7401-
break;
7402-
}
7382+
/* C/C++ `typedef struct { … } Name;` is named by extract_c_typedef from
7383+
* the type_definition; naming the anonymous specifier here as well
7384+
* emitted Name twice (members twice, a false variant). */
74037385
default:
74047386
break;
74057387
}

0 commit comments

Comments
 (0)