Index

An "index" that consists of a set of translation units that would typically be linked together into an executable or library.

Provides a shared context for creating translation units.

It provides two options:

- excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local" declarations (when loading any new translation units). A "local" declaration is one that belongs in the translation unit itself and not in a precompiled header that was used by the translation unit. If zero, all declarations will be enumerated.

Here is an example:

struct Index {
ContainIndex cx;
}

Postblit

Copying this object is disabled.

A postblit is present on this object, but not explicitly documented in the source.

Alias This

cx

Examples

1 // excludeDeclsFromPCH = 1, displayDiagnostics=1
2 Idx = clang_createIndex(1, 1);
3 
4 // IndexTest.pch was produced with the following command:
5 // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
6 TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
7 
8 // This will load all the symbols from 'IndexTest.pch'
9 clang_visitChildren(clang_getTranslationUnitCursor(TU),
10                     TranslationUnitVisitor, 0);
11 clang_disposeTranslationUnit(TU);
12 
13 // This will load all the symbols from 'IndexTest.c', excluding symbols
14 // from 'IndexTest.pch'.
15 char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
16 TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
17                                                0, 0);
18 clang_visitChildren(clang_getTranslationUnitCursor(TU),
19                     TranslationUnitVisitor, 0);
20 clang_disposeTranslationUnit(TU);

This process of creating the 'pch', loading it separately, and using it (via -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks (which gives the indexer the same performance benefit as the compiler).

Meta