Clang (libclang) performing analysis / reprocessing Translation Unit

I have a question about parsing performance when using clang (libclang) and the special function clang_parseTranslationUnit and clang_reparseTranslationUnit.

I am trying to optimize the process, but I have no ideas. The situation is this: I have a .cpp source that contains many header files. These headings change very rarely. However, the .cpp source changes a lot and I need to repeat it often. Thus, it is possible to "prepare / precompile" all the headers and create a .pch file, and then use it when parsing .cpp. However, the problem is that I can only use one .pch. So, I need to create .pch from all included headers. However, later, when I include some other header file, I need to review all the headers, even if they have not changed at all. Also, it is a problem that I should explicitly know which headers are included in .cpp (this is not very convenient, as this will mean that I have to scan, at least for myself, and then create .pch and then use it when parsing the .cpp source).

Is there any other way to optimize the process? I was hoping that when I use clang_parseTranslationUnit and later clang_reparseTranslationUnit, the parsing will actually be optimized this way (at least all the headers that haven't changed don't need to be redrawn again). But that does not work.

+7
source share

All Articles