-
Notifications
You must be signed in to change notification settings - Fork 85
Description
Description
A feature that is badly needed for the application of AI models for C++ code is the ability to build a reduced context for large C++ code bases where only a minimal context is extracted and used to generate a prompt for a large language model (LLM). The problem is that the large C++ code bases can't fit in the prompt for even the best LLM models and providing extra C++ code that does not provide context just confuses the LLM and degrades performance. (And passing in a large set of code greatly increases the number of input tokens and significantly increases the cost to run an LLM.)
What is needed is a tool where you can point to selections of C++ "code of interest" (e.g., some functions, classes, or just few lines of C++ code), and then goes off and recursively looks up all of the classes, functions, variables, etc. that are used in that "code of interest" and produces a listing of C++ code as context with just those upstream dependencies. What this does is to basically take a very large C++ project and turn it into a smaller C++ project (at least for what the LLM needs to know).
The need for this is type of context gathering is described in the paper:
- "YABLoCo: Yet Another Benchmark for Long Context Code Generation", submitted 5/7/2025, https://arxiv.org/abs/2505.04406v1
The basic outline of such a tool based on LLVM is described in the paper:
- "CITYWALK: Enhancing LLM-Based C++ Unit Test Generation via Project-Dependency Awareness and Language-Specific Knowledge", submitted 1/27/2025, https://arxiv.org/abs/2501.16155
This current MCP server has the tools:
definition
: Retrieves the complete source code definition of any symbol (function, type, constant, etc.) from your codebase.hover
: Display documentation, type hints, or other hover information for a given location.
It seems that using those you might be able to recursively construct a narrow C++ context for a given piece of C++ "code of interest".
Claude 4.0 suggests this is what you need to do:
So does Gemini 2.5 flash: