Skip to content

Commit fe6deaa

Browse files
committed
fix(extraction): parse C++ branch views under the terminated-last-line rule
Merging main brought extract_cpp_branch_views (conditional variants), which built its CBMStringInput with the two-field initializer. With this branch's virtual_newline field that is a missing initializer, an error under GCC's -Wextra -Werror (the shadow job's product build). A branch view keeps the raw source's length and line structure, so it now goes through cbm_parse_source like the raw parse: the same virtual newline, and the same edit that removes it again. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent af01531 commit fe6deaa

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎internal/cbm/cbm.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2267,8 +2267,6 @@ static void extract_cpp_branch_views(const CBMExtractCtx *raw, const TSLanguage
22672267
return;
22682268
}
22692269
ts_parser_reset(parser);
2270-
CBMStringInput input = {view, (uint32_t)raw->source_len};
2271-
TSInput ts_input = {&input, cbm_string_read, TSInputEncodingUTF8, NULL};
22722270
TSParseOptions opts = {0};
22732271
CBMParseBudget budget = {0}; // cppcheck-suppress unreadVariable
22742272
if (timeout_micros > 0) {
@@ -2278,7 +2276,9 @@ static void extract_cpp_branch_views(const CBMExtractCtx *raw, const TSLanguage
22782276
opts.payload = &budget;
22792277
opts.progress_callback = cbm_timeout_cb;
22802278
}
2281-
TSTree *tree = ts_parser_parse_with_options(parser, NULL, ts_input, opts);
2279+
/* A view keeps the raw source's length and line structure, so it is
2280+
* parsed under the same terminated-last-line rule (#2078). */
2281+
TSTree *tree = cbm_parse_source(parser, view, (uint32_t)raw->source_len, opts);
22822282
if (!tree) {
22832283
return;
22842284
}

0 commit comments

Comments
 (0)