When using libclang
, the Clang C interface for parsing C/C++ code, clang_reparseTranslationUnit
can be used to update an existing CXTranslationUnit
rather than creating an entirely new one. This allows you to reparse the source files in case there are changes while preserving the already parsed information for unchanged files, such as headers. By doing this, parsing will be faster as it avoids reparsing the unchanged header files.
Here's a step-by-step guide on how to use clang_reparseTranslationUnit
:
- Create a
CXIndex
: The first step is to create an index object that will be used throughout the parsing process.
CXIndex index = clang_createIndex(0, 0);