Table of Contents

llmcpp (Project)

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:

__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