ΒΆint clang_reparseTranslationUnit(
    CXTranslationUnit TU,
    unsigned int num_unsaved_files,
    struct CXUnsavedFile* unsaved_files,
    unsigned int options)

Description

Reparse the source files that produced this translation unit. This routine can be used to re-parse the source files that originally created the given translation unit, for example because those source files have changed (either on disk or as passed via \p unsaved_files). The source code will be reparsed with the same command-line options as it was originally parsed. Reparsing a translation unit invalidates all cursors and source locations that refer into that translation unit. This makes reparsing a translation unit semantically equivalent to destroying the translation unit and then creating a new translation unit with the same command-line arguments. However, it may be more efficient to reparse a translation unit using this routine.

Declared at: clang/include/clang-c/Index.h:1602

Parameters

CXTranslationUnit TU
The translation unit whose contents will be re-parsed. The translation unit must originally have been built with\c clang_createTranslationUnitFromSourceFile().
unsigned int num_unsaved_files
The number of unsaved file entries in \p unsaved_files.
struct CXUnsavedFile* unsaved_files
The files that have not yet been saved to disk but may be required for parsing, including the contents of those files. The contents and name of these files (as specified by CXUnsavedFile) are copied when necessary, so the client only needs to guarantee their validity until the call to this function returns.
unsigned int options
A bitset of options composed of the flags in CXReparse_Flags. The function \c clang_defaultReparseOptions() produces a default set of options recommended for most uses, based on the translation unit.

Returns

0 if the sources could be reparsed. A non-zero error code will be returned if reparsing was impossible, such that the translation unit is invalid. In such cases, the only valid call for \c TU is\c clang_disposeTranslationUnit(TU). The error codes returned by this routine are described by the \c CXErrorCode enum.