I'm working on text editor (almost IDE) and i'm using llvm/clang behind the scenes (tokenizing, diagnostics). Almost every file that is edited includes main header file which includes some headers too which include some other headers (tree of included files):
UserFile.h
L----MainHeader.h
L----string.h
L----device.h
| L----(in some conditions)---concreteDevice.h
L----math.h
|
...
The main idea is skip reparsing headers that remain the same during editing 'UserFile.cpp' in clang_parseTranslationUnit and clang_reparseTranslationUnit invocations.
I've read about Clang's chained precompiled headers or even modules which seems to be what i need.
I've generated PCH for MainHeader.h like clang++ -x c++-header MainHeader.h -emit-pch -o MainHeader.h.pch and used it like clang++ -include-pch MainHeader.h.pch .... I'm not sure if it's PCH for the whole headers tree (chained) or for that file only (most likely).
Do i need chained precompiled headers since there is CXTranslationUnit_PrecompiledPreamble clang option?
How can i generate chained precompiled headers?
Headers tree is pretty complicated because of multiple #ifdef SOME_CONDITION .. #include <SomeHeader.h> #endif and it's pretty difficult to understand the whole tree and precompile PCH for each header file manually (but i do know arguments -DSOME_CONDITION to pass which affect inclusions tree).