Skip to content

bug for parse c++ #946

Description

@chen135790

Version

codebase-memory-mcp v0.8.1

Platform

Linux (x64)

Install channel

GitHub release archive / install.sh / install.ps1

Binary variant

standard

What happened, and what did you expect?

When a C++ file contains #ifdef / #else / #endif blocks around function signatures, the tree-sitter C++ parser silently skips all code from that point until a much later line, resulting in massive gaps in the knowledge graph.

Reproduction

File: SurfaceFlinger.cpp (11,657 lines)

Trigger pattern (line 2064):

#ifdef FLYME_GRAPHICS_EXTEND_LUMARGB
status_t SurfaceFlinger::addRegionSamplingListener(const Rect& samplingArea,
                                                   const sp<IBinder>& stopLayerHandle,
                                                   const sp<IRegionSamplingListener>& listener,
                                                   const bool rgbSample) {
#else
status_t SurfaceFlinger::addRegionSamplingListener(const Rect& samplingArea,
                                                   const sp<IBinder>& stopLayerHandle,
                                                   const sp<IRegionSamplingListener>& listener) {
#220 

### Logs

```text
## Bug Description

When a C++ file contains `#ifdef` / `#else` / `#endif` blocks around function signatures, the tree-sitter C++ parser silently skips all code from that point until a much later line, resulting in massive gaps in the knowledge graph.

## Reproduction

**File:** `SurfaceFlinger.cpp` (11,657 lines)

**Trigger pattern (line 2064):**

#ifdef FLYME_GRAPHICS_EXTEND_LUMARGB
status_t SurfaceFlinger::addRegionSamplingListener(const Rect& samplingArea,
                                                   const sp<IBinder>& stopLayerHandle,
                                                   const sp<IRegionSamplingListener>& listener,
                                                   const bool rgbSample) {
#else
status_t SurfaceFlinger::addRegionSamplingListener(const Rect& samplingArea,
                                                   const sp<IBinder>& stopLayerHandle,
                                                   const sp<IRegionSamplingListener>& listener) {
#endif
Result:
- Methods indexed: lines 4632065, then 1061911637
- Gap: lines 206610618 (~8,552 lines) completely missing from graph
- Critical methods SurfaceFlinger::commit (line 2758) and SurfaceFlinger::composite (line 3007) are not indexed
Expected Behavior
All methods in the file should be indexed regardless of #ifdef blocks around signatures.
Actual Behavior
The parser appears to bail when encountering duplicate function signatures in #ifdef/#else branches, skipping everything until it finds a "clean" parse point ~8,500 lines later.
Impact
This affects any C/C++ codebase using conditional compilation for platform-specific or feature-flag variants of function signatures — very common in Android/AOSP, Linux kernel, and embedded projects.
Environment
- codebase-memory-mcp v0.8.1
- Linux amd64
- Indexing mode: full / moderate / fast (all exhibit the same gap)

Diagnostics trajectory (memory / performance / leak issues)

**File:** `SurfaceFlinger.cpp` (11,657 lines)

**Trigger pattern (line 2064):**

#ifdef FLYME_GRAPHICS_EXTEND_LUMARGB
status_t SurfaceFlinger::addRegionSamplingListener(const Rect& samplingArea,
                                                   const sp<IBinder>& stopLayerHandle,
                                                   const sp<IRegionSamplingListener>& listener,
                                                   const bool rgbSample) {
#else
status_t SurfaceFlinger::addRegionSamplingListener(const Rect& samplingArea,
                                                   const sp<IBinder>& stopLayerHandle,
                                                   const sp<IRegionSamplingListener>& listener) {
#endif

Project scale (if relevant)

No response

Confirmations

  • I searched existing issues and this is not a duplicate.
  • My reproduction uses shareable code (a dummy snippet or a public OSS repository), not proprietary code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingparsing/qualityGraph extraction bugs, false positives, missing edgespriority/normalStandard review queue; useful PR with ordinary maintainer urgency.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions