Latest Posts

Code Completion in Clang Repl

Clang-Repl, featuring a REPL(Read-Eval-Print-Loop) environment, allows developers to program in C++ interactively. It is a C++ interpreter built upon the Clang and LLVM incremental compilation pipeline. One of the missing upstream features in Clang-Repl is the ability to propose options for automatically completing user input or code completion. Sometimes, C++ can be quite wordy, requiring users to type every character of an expression or statement. Consequently, this causes typos or syntactic errors.

Read more here

Driving Collaboration in Documentation: Google Season of Docs 2023

A review of the documentation efforts in 2023, powered by Google's Season of Docs initiative. An audit of the existing documentation was done to identify gaps and potential areas of improvement. Our main areas of focus were: Automatic Differentiation applications (using Clad, e.g. in RooFit and Floating-Point Error Estimation), and Python-C++ Interoperability (Clang-Repl (LLVM), CppInterOp, cppyy, Numba, etc.).

Read more here

Shared Memory Based JITLink Memory Manager

LLVM JIT APIs include JITLink, a just-in-time linker that links together objects code units directly in memory and executes them. It uses the JITLinkMemoryManager interface to allocate and manage memory for the generated code. When the generated code is run in the same process as the linker, memory is directly allocated using OS APIs. But for code that runs in a separate executor process, an RPC scheme Executor Process Control (EPC) is used. The controller process invokes RPCs in the target or executor process to allocate memory and then when the code is generated, all the section contents are transferred through finalize calls.

Read more here

Recovering from Errors in Clang-Repl and Code Undo

Incremental C++ enables exploratory programming by considering the translation unit to be an ever-growing entity. This allows implementation of interpreter-like tools such as Cling and Clang-Repl, which consume C++ code piece by piece and use the JIT infrastructure to run each piecewise. One of the challenges of Incremental C++ is the reliable recovery from errors which allows the session to continue after faulty user code. Supporting reliable error recovery requires splitting the translation unit into a sequence of Partial Translation Units (PTUs). Each declaration is associated with a unique PTU that owns it. Owning PTU isn’t always the “active” (most recent) PTU and it isn’t always the PTU that the declaration comes from. Even a new declaration that isn’t a declaration or or specialization of anything belongs to the active PTU. However, in case of a template specialization, it can be pulled into a more recent PTU by its template arguments.

Read more here

Extend Clang to Resugar Template Specialization Accesses

Clang is an LLVM native C/C++/Objective-C compiler, which aims to deliver amazingly fast compiles, extremely useful error and warning messages and to provide a platform for building great source level tools. The Clang Static Analyzer and clang-tidy are tools that automatically find bugs in your code, and are great examples of the sort of tools that can be built using the Clang frontend as a library to parse C/C++ code. When instantiating a template, the template arguments are canonicalized before being substituted into the template pattern. Clang does not preserve type sugar when subsequently accessing members of the instantiation. This leads to many infamous pathological errors which have haunted C++ developers for decades.

Read more here