test(c-lsp): regression for #220 (C++ CALLS attributed to function)

#220: C++ CALLS edges originated from the Module node instead of the
enclosing Function, breaking function-level trace_path. The cross-LSP
resolver now sets caller_qn = enclosing_func_qn; the test asserts a call
(doWork→helper) is attributed to doWork, not the module.

Closes #220.
This commit is contained in:
Martin Vogel committed 2026-05-31 11:57:50 +02:00
1 parent 53be053d3f
commit 48a9b2c2a9
1 file changed
+17
+17
View File
@@ -583,6 +583,22 @@ TEST(clsp_nocrash_template_function_multi_param_nested_call) {
PASS();
}
/* Issue #220: C++ CALLS edges were attributed to the Module (file) node
* instead of the enclosing Function/Method, breaking function-level
* trace_path. The resolved call's caller_qn must be the enclosing function. */
TEST(clsp_calls_attributed_to_function_issue220) {
CBMFileResult *r = extract_cpp("void helper() {}\n"
"void doWork() {\n"
" helper();\n"
"}\n");
ASSERT_NOT_NULL(r);
int idx = find_resolved(r, "doWork", "helper");
ASSERT_GTE(idx, 0);
ASSERT_NOT_NULL(strstr(r->resolved_calls.items[idx].caller_qn, "doWork"));
cbm_free_result(r);
PASS();
}
/* Issue #355: indexing segfaulted while extracting a heavily-macro'd xxhash
* C header (`dhw/xx_hash.h`). The reporter's exact file isn't available, so
* this drives the vendored xxhash.h (~7.5k lines, same macro-dense family)
@@ -15196,6 +15212,7 @@ SUITE(c_lsp) {
RUN_TEST(clsp_nocrash_template_expression);
RUN_TEST(clsp_nocrash_template_extra_call_args);
RUN_TEST(clsp_nocrash_template_function_multi_param_nested_call);
RUN_TEST(clsp_calls_attributed_to_function_issue220);
RUN_TEST(clsp_nocrash_issue355_xxhash_header);
RUN_TEST(clsp_nocrash_issue312_default_template_auto_param);
RUN_TEST(clsp_nocrash_lambda);