From 48a9b2c2a9dcca91bc3a5c8d8f6f9f6572fc6c94 Mon Sep 17 00:00:00 2001 From: Martin Vogel Date: Sun, 31 May 2026 11:57:50 +0200 Subject: [PATCH] test(c-lsp): regression for #220 (C++ CALLS attributed to function) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #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. --- tests/test_c_lsp.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_c_lsp.c b/tests/test_c_lsp.c index 4c9c06885..48c368fb5 100644 --- a/tests/test_c_lsp.c +++ b/tests/test_c_lsp.c @@ -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);