Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
fix(lsp): resolve C/C++ function-pointer calls via the join (#func_ptr)
Martin Vogelbef9ab08fff8
diff --git a/internal/cbm/lsp/c_lsp.c b/internal/cbm/lsp/c_lsp.cindex 1c6b30c8d..be91bdcaa 100644--- a/internal/cbm/lsp/c_lsp.c+++ b/internal/cbm/lsp/c_lsp.c@@ -3284,8 +3284,8 @@ void c_process_statement(CLSPContext *ctx, TSNode node) {// Emit helpers// ============================================================================-static void c_emit_resolved_call(CLSPContext *ctx, const char *callee_qn, const char *strategy,- float confidence) {+static void c_emit_resolved_call_orig(CLSPContext *ctx, const char *callee_qn, const char *orig,+ const char *strategy, float confidence) {if (!ctx->resolved_calls || !callee_qn || !ctx->enclosing_func_qn)return;CBMResolvedCall rc;@@ -3293,10 +3293,21 @@ static void c_emit_resolved_call(CLSPContext *ctx, const char *callee_qn, constrc.callee_qn = callee_qn;rc.strategy = strategy;rc.confidence = confidence;- rc.reason = NULL;+ // For a data-flow resolution (e.g. a function pointer `fp` resolved to its+ // target), `reason` carries the ORIGINAL textual callee name the LSP+ // resolved FROM, so the pipeline join can match the call site on that name+ // even though it differs from the resolved callee_qn's short name. `reason`+ // is otherwise NULL for resolved calls and is never read for them by the+ // pipeline consumers, so this overload is side-effect-free.+ rc.reason = orig;cbm_resolvedcall_push(ctx->resolved_calls, ctx->arena, rc);}+static void c_emit_resolved_call(CLSPContext *ctx, const char *callee_qn, const char *strategy,+ float confidence) {+ c_emit_resolved_call_orig(ctx, callee_qn, NULL, strategy, confidence);+}+static void c_emit_unresolved_call(CLSPContext *ctx, const char *expr_text, const char *reason) {if (!ctx->resolved_calls || !ctx->enclosing_func_qn)return;@@ -3601,9 +3612,12 @@ static void c_resolve_calls_in_node_inner(CLSPContext *ctx, TSNode node) {if (fp_target) {// Distinguish DLL/dynamic resolution from static fp targetsbool is_dll = (strncmp(fp_target, "external.", 9) == 0);- c_emit_resolved_call(ctx, fp_target,- is_dll ? "lsp_dll_resolve" : "lsp_func_ptr",- is_dll ? 0.80f : 0.85f);+ // The textual callee is the pointer variable `name` (e.g.+ // `fp`), resolved to a differently named target. Pass it+ // as orig so the join matches the call on the pointer name.+ c_emit_resolved_call_orig(ctx, fp_target, name,+ is_dll ? "lsp_dll_resolve" : "lsp_func_ptr",+ is_dll ? 0.80f : 0.85f);goto recurse;}diff --git a/src/pipeline/lsp_resolve.h b/src/pipeline/lsp_resolve.hindex 28dcb9474..5a942a196 100644--- a/src/pipeline/lsp_resolve.h+++ b/src/pipeline/lsp_resolve.h@@ -105,7 +105,17 @@ static inline const CBMResolvedCall *cbm_pipeline_find_lsp_resolution(* calls (bare callee_name) are unaffected. */const char *call_short = cbm_lsp_bare_segment(call->callee_name);if (strcmp(short_name, call_short) != 0) {- continue;+ /* Data-flow resolution: a function-pointer / DLL call's textual+ * callee is the pointer name (`fp`), which the LSP resolved to a+ * differently-named target and stashed in `reason`. Match the call+ * site on that original name, gated to those strategies so `reason`+ * is never misread as an unresolved-call diagnostic. */+ if (!(rc->reason && rc->strategy &&+ (strcmp(rc->strategy, "lsp_func_ptr") == 0 ||+ strcmp(rc->strategy, "lsp_dll_resolve") == 0) &&+ strcmp(cbm_lsp_bare_segment(rc->reason), call_short) == 0)) {+ continue;+ }}if (!best || rc->confidence > best->confidence) {best = rc;