Skip to content

fix(cpp): resolve using-alias and typedef constructions to the aliased class - #797

Merged
vitali87 merged 11 commits into
mainfrom
fix/cpp-alias-construction
Jul 18, 2026
Merged

fix(cpp): resolve using-alias and typedef constructions to the aliased class#797
vitali87 merged 11 commits into
mainfrom
fix/cpp-alias-construction

Conversation

@vitali87

Copy link
Copy Markdown
Owner

Problem

using appender = basic_appender<char>; appender(out) constructs the aliased class, but the alias is not a registered node, so the bare call resolved to nothing and the class's constructor kept zero incoming edges. fmt's basic_appender.basic_appender stayed on the dead list after #791 for exactly this reason (every construction site spells the alias). Third follow-up from the #791 residual audit.

Fix

call_processor.py: in the unresolved-bare-name fallback chain, a C++ call name that appears in the collected typedef/using alias map and that _resolve_class_name (which follows alias chains and requires registration) binds to a registered class becomes a class callee. It then drops into the existing class branch, which emits INSTANTIATES plus the constructor CALLS redirect like any direct construction. Gated on alias-map membership, so genuinely unknown names keep their unresolved handling, and an alias to a non-class (using count_t = int; functional casts) stays edge-free.

Validation

  • Dead-code scoreboard: fmt 629 -> 628 (basic_appender.basic_appender revived — the predicted FP), nlohmann stable at 261. Zero newly-dead entries; revive-only change.
  • Full C++ test subset (420) green.

Tests

RED -> GREEN: test_cpp_alias_construction.pyusing alias, template alias (using view = basic_view<int>), typedef, and the alias-to-primitive negative control.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for resolving C++ alias constructions (such as using and typedef declarations) to their underlying classes, ensuring that INSTANTIATES and constructor CALLS relationships are correctly captured. It also adds comprehensive unit tests to verify this behavior. The reviewer suggested a minor improvement in the test helper function to compare enum members directly rather than converting them to strings.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread codebase_rag/tests/test_cpp_alias_construction.py
@greptile-apps

greptile-apps Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR updates C++ alias construction resolution. The main changes are:

  • Resolves unresolved bare C++ calls through visible typedef and using aliases when they point to registered classes.
  • Adds caller-local alias collection with declaration-order and lexical-scope windows.
  • Reuses the existing class construction path to emit INSTANTIATES and constructor CALLS edges.
  • Adds tests for global aliases, template aliases, typedefs, function-local aliases, scoped aliases, shadowing, local struct member aliases, and primitive-alias negatives.
  • Bumps the editable project version in uv.lock.

Confidence Score: 5/5

Safe to merge with low risk.

The change is narrowly gated to unresolved C++ bare calls whose alias resolves to a registered class. Tests cover the main positive paths and the prior scoping edge cases. No accepted issues remain.

No files require special attention.

T-Rex T-Rex Logs

What T-Rex did

  • T-Rex attempted the primary pytest run for the focused codepath and captured the blocked command and environment blocker after recreating the virtual environment.
  • T-Rex performed environment restoration by re-running dependency restoration to reconstitute a usable test environment.
  • T-Rex observed a fixture blocker during focused pytest collection and setup when patching codebase_rag.cli.
  • T-Rex validated a workaround by running pytest with a minimal sitecustomize shim, which allowed all tests to pass (nine tests).

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
codebase_rag/parsers/call_processor.py Adds C++ unresolved bare-call alias fallback that resolves visible typedef/using aliases to registered classes before existing construction edge emission.
codebase_rag/parsers/cpp/type_inference.py Adds caller-scoped C++ alias collection with declaration and lexical scope windows for local alias construction resolution.
codebase_rag/tests/test_cpp_alias_construction.py Adds regression tests for alias construction positives and scoped negative cases.
uv.lock Bumps the editable project version from 0.0.377 to 0.0.378.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Unresolved C++ bare call] --> B[Collect caller-local typedef/using aliases once]
B --> C{Local alias window contains call?}
C -- yes --> D[Use alias underlying name with latest declaration]
C -- no --> E[Use original call name]
D --> F{Underlying resolves to registered class?}
E --> G{Call name exists in global alias map?}
G -- yes --> F
G -- no --> H[Continue unresolved fallback chain]
F -- yes --> I[Set callee to CLASS]
F -- no --> H
I --> J[Existing class branch emits INSTANTIATES and constructor CALLS]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[Unresolved C++ bare call] --> B[Collect caller-local typedef/using aliases once]
B --> C{Local alias window contains call?}
C -- yes --> D[Use alias underlying name with latest declaration]
C -- no --> E[Use original call name]
D --> F{Underlying resolves to registered class?}
E --> G{Call name exists in global alias map?}
G -- yes --> F
G -- no --> H[Continue unresolved fallback chain]
F -- yes --> I[Set callee to CLASS]
F -- no --> H
I --> J[Existing class branch emits INSTANTIATES and constructor CALLS]
Loading

Reviews (6): Last reviewed commit: "fix(cpp): scope local-struct member alia..." | Re-trigger Greptile

Comment thread codebase_rag/parsers/call_processor.py Outdated
@vitali87

Copy link
Copy Markdown
Owner Author

@greptile review

Comment thread codebase_rag/parsers/cpp/type_inference.py Outdated
@vitali87

Copy link
Copy Markdown
Owner Author

@greptile review

Comment thread codebase_rag/parsers/cpp/type_inference.py
@vitali87

Copy link
Copy Markdown
Owner Author

@greptile review

Comment thread codebase_rag/parsers/cpp/type_inference.py Outdated
@vitali87

Copy link
Copy Markdown
Owner Author

@greptile review

Comment thread codebase_rag/parsers/cpp/type_inference.py Outdated
@vitali87

Copy link
Copy Markdown
Owner Author

@greptile review

@sonarqubecloud

Copy link
Copy Markdown

@vitali87
vitali87 merged commit dffd00d into main Jul 18, 2026
23 checks passed
@vitali87
vitali87 deleted the fix/cpp-alias-construction branch July 18, 2026 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant