From 094798199ba8098cd33b834dd17b4b8933e14e09 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 14 May 2026 18:06:06 +0000 Subject: [PATCH] test(cpp): isolate primitive ref ADL negative and add const-ref coverage Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/3806db7d-1ec8-4cf4-a4fb-e9a755365d4b --- gitnexus/src/core/ingestion/languages/cpp/adl.ts | 2 -- gitnexus/src/core/ingestion/languages/cpp/captures.ts | 6 ++---- .../cpp-adl-reference-arg-boundary/app.cpp | 6 ++++++ .../cpp-adl-reference-arg-boundary/audit.h | 2 -- .../cpp-adl-reference-arg-boundary/record.h | 8 ++++++++ gitnexus/test/integration/resolvers/cpp.test.ts | 11 ++++++++++- 6 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 gitnexus/test/fixtures/lang-resolution/cpp-adl-reference-arg-boundary/record.h diff --git a/gitnexus/src/core/ingestion/languages/cpp/adl.ts b/gitnexus/src/core/ingestion/languages/cpp/adl.ts index ca56a01d1..ec1c83e49 100644 --- a/gitnexus/src/core/ingestion/languages/cpp/adl.ts +++ b/gitnexus/src/core/ingestion/languages/cpp/adl.ts @@ -72,8 +72,6 @@ export interface CppAdlArgInfo { /** True when the variable's declarator contained one or more * `pointer_declarator` wrappers. */ readonly isPointer: boolean; - /** True when the variable's declarator was a `reference_declarator`. */ - readonly isReference: boolean; } const argInfoBySite = new Map(); diff --git a/gitnexus/src/core/ingestion/languages/cpp/captures.ts b/gitnexus/src/core/ingestion/languages/cpp/captures.ts index 9283ec0a5..9bd2cbef9 100644 --- a/gitnexus/src/core/ingestion/languages/cpp/captures.ts +++ b/gitnexus/src/core/ingestion/languages/cpp/captures.ts @@ -743,7 +743,7 @@ function inferCppCallAdlArgs(callNode: SyntaxNode): CppAdlArgInfo[] { return out; } -const EMPTY_ADL_ARG: CppAdlArgInfo = { simpleClassName: '', isPointer: false, isReference: false }; +const EMPTY_ADL_ARG: CppAdlArgInfo = { simpleClassName: '', isPointer: false }; function classifyAdlArg(argNode: SyntaxNode): CppAdlArgInfo { // Literals and primitive-shaped expressions never have associated namespaces. @@ -800,7 +800,6 @@ function lookupAdlIdentifierType(identNode: SyntaxNode): CppAdlArgInfo { // Function-pointer wrappers (`pointer_declarator > function_declarator`) // must not contribute ADL associated namespaces. let isPointer = false; - let isReference = false; let isFunctionPointer = false; let inner: SyntaxNode = declarator; let nameText: string | null = null; @@ -818,7 +817,6 @@ function lookupAdlIdentifierType(identNode: SyntaxNode): CppAdlArgInfo { continue; } if (inner.type === 'reference_declarator' || inner.type === 'rvalue_reference_declarator') { - isReference = true; // reference_declarator has a single child (the inner declarator). let next: SyntaxNode | null = null; for (let j = 0; j < inner.namedChildCount; j++) { @@ -849,7 +847,7 @@ function lookupAdlIdentifierType(identNode: SyntaxNode): CppAdlArgInfo { if (isFunctionPointer || nameText !== varName) continue; const simpleClassName = extractAdlSimpleTypeName(typeNode); - return { simpleClassName, isPointer, isReference }; + return { simpleClassName, isPointer }; } return EMPTY_ADL_ARG; } diff --git a/gitnexus/test/fixtures/lang-resolution/cpp-adl-reference-arg-boundary/app.cpp b/gitnexus/test/fixtures/lang-resolution/cpp-adl-reference-arg-boundary/app.cpp index bb94cf868..b5b78e590 100644 --- a/gitnexus/test/fixtures/lang-resolution/cpp-adl-reference-arg-boundary/app.cpp +++ b/gitnexus/test/fixtures/lang-resolution/cpp-adl-reference-arg-boundary/app.cpp @@ -7,6 +7,12 @@ namespace app { record(s); } + void runConstRef() { + audit::Event e; + const audit::Event& cs = e; + recordConst(cs); + } + void runPrimitiveRef() { int n = 0; int& r = n; diff --git a/gitnexus/test/fixtures/lang-resolution/cpp-adl-reference-arg-boundary/audit.h b/gitnexus/test/fixtures/lang-resolution/cpp-adl-reference-arg-boundary/audit.h index ddd7d3f23..4b4600381 100644 --- a/gitnexus/test/fixtures/lang-resolution/cpp-adl-reference-arg-boundary/audit.h +++ b/gitnexus/test/fixtures/lang-resolution/cpp-adl-reference-arg-boundary/audit.h @@ -2,6 +2,4 @@ namespace audit { struct Event {}; - void record(Event& e); - void note(int& n); } diff --git a/gitnexus/test/fixtures/lang-resolution/cpp-adl-reference-arg-boundary/record.h b/gitnexus/test/fixtures/lang-resolution/cpp-adl-reference-arg-boundary/record.h new file mode 100644 index 000000000..590ac5a87 --- /dev/null +++ b/gitnexus/test/fixtures/lang-resolution/cpp-adl-reference-arg-boundary/record.h @@ -0,0 +1,8 @@ +#pragma once + +#include "audit.h" + +namespace audit { + void record(Event& e); + void recordConst(const Event& e); +} diff --git a/gitnexus/test/integration/resolvers/cpp.test.ts b/gitnexus/test/integration/resolvers/cpp.test.ts index 4b5d7c793..025fcb462 100644 --- a/gitnexus/test/integration/resolvers/cpp.test.ts +++ b/gitnexus/test/integration/resolvers/cpp.test.ts @@ -2175,7 +2175,16 @@ describe('C++ ADL — reference arg unwrapping', () => { const calls = getRelationships(result, 'CALLS'); const recordCalls = calls.filter((c) => c.source === 'runRef' && c.target === 'record'); expect(recordCalls.length).toBe(1); - expect(recordCalls[0].targetFilePath).toContain('audit.h'); + expect(recordCalls[0].targetFilePath).toContain('record.h'); + }); + + it('recordConst(cs) where cs is const audit::Event& resolves via ADL', () => { + const calls = getRelationships(result, 'CALLS'); + const recordCalls = calls.filter( + (c) => c.source === 'runConstRef' && c.target === 'recordConst', + ); + expect(recordCalls.length).toBe(1); + expect(recordCalls[0].targetFilePath).toContain('record.h'); }); it('note(r) where r is int& emits zero CALLS edges (primitive ref)', () => {