# llmcpp (Project) **[llmcpp](https://github.com/yanevskiv/llmcpp)** is a project I built to generate C++ function bodies from plain-language instructions during compilation. Its `llmc++` compiler driver is based on Clang 19 and adds an `__llm__` modifier for functions, methods, and lambdas. The declaration stays in C++, while the body describes the behavior I want. The driver uses Clang to understand the surrounding program. A generation agent receives the function's task and can ask compiler tools about names, types, members, and captures. It can test candidate implementations using compiler diagnostics before submitting a body. The agent does not receive the complete raw source file; it works with the task and the compiler context exposed through these tools. Accepted implementations replace the prompt bodies, and the rewritten source continues through normal compilation. Generation happens at build time, so the finished program calls ordinary compiled functions without contacting a model. A body cache lets later builds reuse accepted code, and offline mode requires those cached implementations instead of starting another generation exchange. For example, this source asks for a function that doubles an integer: ```cpp __llm__ int twice(int value) { Return twice value. } int main() { return twice(3) == 6 ? 0 : 1; } ``` With a generation backend configured, compile it with `llmc++ main.cpp -o main`. Use `llmc++ --llm -fllm-offline main.cpp` afterward to inspect the cached implementation in `main.llm.cpp`. The project supports native API clients and external agents, as well as transcripts and deterministic test fixtures. Successful compilation checks that the body is valid C++; review and behavioral tests check whether it fulfills the request. ## Concepts - [[llmcpp-compiler-driver|Compiler driver]] - [[llmcpp-clang-integration|Clang integration]] - [[llmcpp-compilation-pipeline|Compilation pipeline]] - [[llmcpp-source-rewriting|Source rewriting]] - [[llmcpp-llm-modifier|__llm__ modifier]] - [[llmcpp-prompt-bodies|Prompt bodies]] - [[llmcpp-per-function-settings|Per-function settings]] - [[llmcpp-generated-methods|Generated methods]] - [[llmcpp-generated-lambdas|Generated lambdas]] - [[llmcpp-generated-templates|Generated templates]] - [[llmcpp-compiler-context|Compiler context]] - [[llmcpp-abstract-syntax-tree|Abstract syntax tree]] - [[llmcpp-name-lookup|Name lookup]] - [[llmcpp-type-inspection|Type inspection]] - [[llmcpp-member-inspection|Member inspection]] - [[llmcpp-lambda-captures|Lambda captures]] - [[llmcpp-code-generation|Code generation]] - [[llmcpp-system-prompts|System prompts]] - [[llmcpp-reference-context|Reference context]] - [[llmcpp-candidate-compilation|Candidate compilation]] - [[llmcpp-compiler-diagnostics|Compiler diagnostics]] - [[llmcpp-body-submission|Body submission]] - [[llmcpp-generation-limits|Generation limits]] - [[llmcpp-agent-backends|Agent backends]] - [[llmcpp-native-api-clients|Native API clients]] - [[llmcpp-external-agents|External agents]] - [[llmcpp-json-rpc|JSON-RPC]] - [[llmcpp-model-context-protocol|Model Context Protocol (MCP)]] - [[llmcpp-caching|Caching]] - [[llmcpp-cache-identity|Cache identity]] - [[llmcpp-explicit-cache-keys|Explicit cache keys]] - [[llmcpp-cache-lifetime|Cache lifetime]] - [[llmcpp-read-only-caching|Read-only caching]] - [[llmcpp-offline-compilation|Offline compilation]] - [[llmcpp-forced-regeneration|Forced regeneration]] - [[llmcpp-inspecting-generation|Inspecting generation]] - [[llmcpp-generated-source-output|Generated-source output]] - [[llmcpp-context-dumps|Context dumps]] - [[llmcpp-generation-transcripts|Generation transcripts]] - [[llmcpp-transcript-replay|Transcript replay]] - [[llmcpp-testing|Testing]] - [[llmcpp-mock-agents|Mock agents]] - [[llmcpp-backend-test-servers|Backend test servers]] - [[llmcpp-behavioral-correctness|Behavioral correctness]]