If you are following the cfe-commits mailing list, you may have noticed that a new ‘Index’ library (referred to as ‘clangIndex’ from now on) has “landed” on the clang repository recently.
I’d like to make a proper introduction of this new library.
ClangIndex is meant to provide the basic infrastructure for cross-translation-unit analysis and is primarily focused on indexing related functionality.
It provides an API for clients that need to accurately map the AST nodes of the ASTContext to the locations in the source files.
It also allows them to analyze information across multiple translation units.
As a “general rule”, ASTContexts are considered the primary source of information that a client wants about a translation unit.
As a consequence, there will be no such class as an “indexing database” that stores, for example, source locations of identifiers separately from ASTContext.
All the information that a client needs from a translation unit will be extracted from the ASTContext.