codegraph icon indicating copy to clipboard operation
codegraph copied to clipboard

The interface cannot be indexed; the function is decorated with the macro AX_VIN_GLB_API

Open banxiaokun opened this issue 6 months ago • 3 comments

CodeGraph did not directly index the AX_VIN_Init symbol (likely because it is decorated with the AX_VIN_GLB_API macro)

banxiaokun avatar May 28 '26 07:05 banxiaokun

Confirmed the root cause and opened #597.

When a function is written as EXPORT_MACRO ReturnType Name(...) with a project-defined (typedef'd) return type — e.g. AX_VIN_GLB_API AX_S32 AX_VIN_Init(AX_VOID) — tree-sitter-c treats both the macro and the return type as unknown identifiers in type position, peels MACRO RET off as a broken declaration, and parses the real function with its name absorbed as the type field and the params wrapped in a bare parenthesized_declarator. The extractor then indexed it under the name (AX_VOID), so AX_VIN_Init couldn't be found.

#597 recovers the real name from the type field for exactly that shape (with a no-misfire test for valid C like int (foo)(void)). Macro + primitive/pointer return types and all C++ forms already index correctly and are untouched; header-only prototypes are noted as a follow-up.

maxmilian avatar May 31 '26 15:05 maxmilian

Re-checked this on current main (c6aaa20) — it looks fixed.

AX_VIN_Init now indexes under its real name. Repro from a clean checkout:

mkdir /tmp/i515 && cd /tmp/i515
printf 'typedef int AX_S32;\n#define AX_VOID void\n#define AX_VIN_GLB_API\n\nAX_VIN_GLB_API AX_S32 AX_VIN_Init(AX_VOID)\n{\n    return 0;\n}\n' > ax_vin.c
codegraph init
codegraph query AX_VIN_Init
Search Results for "AX_VIN_Init":

function    AX_VIN_Init
  ax_vin.c:5

What fixed it is blankCLeadingAttrMacros, added in b6a05d1 (#1311, for #1211) — it blanks the line-leading ALL-CAPS macro before parsing, so AX_VIN_GLB_API no longer pushes the parameter list into the name slot.

Attribution checked rather than assumed: neutering just that one function (an early return source; in src/extraction/languages/c-cpp.ts:846) on the same main checkout reproduces exactly the symptom reported here.

src/extraction/languages/c-cpp.ts symbol indexed for ax_vin.c
main as-is AX_VIN_Init (function) ✅
blankCLeadingAttrMacros neutered (AX_VOID) (function) ❌

So this one looks like it can be closed.

maxmilian avatar Aug 13 '26 02:08 maxmilian

Thanks for the detailed report, @banxiaokun, and thanks for using CodeGraph! This was fixed by #1311: a leading attribute macro like AX_VIN_GLB_API is now blanked before parsing, so the function is indexed under its real name. That fix shipped in v1.5.0, and we re-verified your case against current main. Upgrading to the latest release and re-indexing (codegraph index) should resolve it.

colbymchenry avatar Sep 27 '26 12:09 colbymchenry