Index: include/clang-c/Index.h =================================================================== --- include/clang-c/Index.h +++ include/clang-c/Index.h @@ -1239,7 +1239,12 @@ /** * \brief Sets the preprocessor in a mode for parsing a single file only. */ - CXTranslationUnit_SingleFileParse = 0x400 + CXTranslationUnit_SingleFileParse = 0x400, + + /** + * \brief Do incremental processing + */ + CXTranslationUnit_IncrementalProcessing = 0x800 }; /** Index: include/clang/Frontend/ASTUnit.h =================================================================== --- include/clang/Frontend/ASTUnit.h +++ include/clang/Frontend/ASTUnit.h @@ -881,6 +881,7 @@ bool AllowPCHWithCompilerErrors = false, bool SkipFunctionBodies = false, bool SingleFileParse = false, bool UserFilesAreVolatile = false, bool ForSerialization = false, + bool IncrementalProcessing = false, llvm::Optional ModuleFormat = llvm::None, std::unique_ptr *ErrAST = nullptr, IntrusiveRefCntPtr VFS = nullptr); Index: include/clang/Lex/Preprocessor.h =================================================================== --- include/clang/Lex/Preprocessor.h +++ include/clang/Lex/Preprocessor.h @@ -1314,12 +1314,10 @@ void recomputeCurLexerKind(); /// \brief Returns true if incremental processing is enabled - bool isIncrementalProcessingEnabled() const { return IncrementalProcessing; } + bool isIncrementalProcessingEnabled() const; /// \brief Enables the incremental processing - void enableIncrementalProcessing(bool value = true) { - IncrementalProcessing = value; - } + void enableIncrementalProcessing(bool value = true); /// \brief Specify the point at which code-completion will be performed. /// Index: include/clang/Lex/PreprocessorOptions.h =================================================================== --- include/clang/Lex/PreprocessorOptions.h +++ include/clang/Lex/PreprocessorOptions.h @@ -98,6 +98,9 @@ /// When enabled, preprocessor is in a mode for parsing a single file only. bool SingleFileParseMode = false; + /// Do incremental processing + bool IncrementalProcessing = false; + /// \brief True if the SourceManager should report the original file name for /// contents of files that were remapped to other files. Defaults to true. bool RemappedFilesKeepOriginalName; Index: lib/Frontend/ASTUnit.cpp =================================================================== --- lib/Frontend/ASTUnit.cpp +++ lib/Frontend/ASTUnit.cpp @@ -1985,8 +1985,8 @@ bool CacheCodeCompletionResults, bool IncludeBriefCommentsInCodeCompletion, bool AllowPCHWithCompilerErrors, bool SkipFunctionBodies, bool SingleFileParse, bool UserFilesAreVolatile, bool ForSerialization, - llvm::Optional ModuleFormat, std::unique_ptr *ErrAST, - IntrusiveRefCntPtr VFS) { + bool IncrementalProcessing, llvm::Optional ModuleFormat, + std::unique_ptr *ErrAST, IntrusiveRefCntPtr VFS) { assert(Diags.get() && "no DiagnosticsEngine was provided"); SmallVector StoredDiagnostics; @@ -2014,6 +2014,7 @@ PPOpts.AllowPCHWithCompilerErrors = AllowPCHWithCompilerErrors; PPOpts.GeneratePreamble = PrecompilePreambleAfterNParses != 0; PPOpts.SingleFileParseMode = SingleFileParse; + PPOpts.IncrementalProcessing = IncrementalProcessing; // Override the resources path. CI->getHeaderSearchOpts().ResourceDir = ResourceFilesPath; Index: lib/Lex/Preprocessor.cpp =================================================================== --- lib/Lex/Preprocessor.cpp +++ lib/Lex/Preprocessor.cpp @@ -942,6 +942,14 @@ return true; } +bool Preprocessor::isIncrementalProcessingEnabled() const { + return PPOpts->IncrementalProcessing; +} + +void Preprocessor::enableIncrementalProcessing(bool value) { + PPOpts->IncrementalProcessing = value; +} + ModuleLoader::~ModuleLoader() { } CommentHandler::~CommentHandler() { } Index: tools/libclang/CIndex.cpp =================================================================== --- tools/libclang/CIndex.cpp +++ tools/libclang/CIndex.cpp @@ -3309,6 +3309,7 @@ bool SkipFunctionBodies = options & CXTranslationUnit_SkipFunctionBodies; bool SingleFileParse = options & CXTranslationUnit_SingleFileParse; bool ForSerialization = options & CXTranslationUnit_ForSerialization; + bool IncrementalProcessing = options & CXTranslationUnit_IncrementalProcessing; // Configure the diagnostics. IntrusiveRefCntPtr @@ -3393,7 +3394,7 @@ /*RemappedFilesKeepOriginalName=*/true, PrecompilePreambleAfterNParses, TUKind, CacheCodeCompletionResults, IncludeBriefCommentsInCodeCompletion, /*AllowPCHWithCompilerErrors=*/true, SkipFunctionBodies, SingleFileParse, - /*UserFilesAreVolatile=*/true, ForSerialization, + /*UserFilesAreVolatile=*/true, ForSerialization, IncrementalProcessing, CXXIdx->getPCHContainerOperations()->getRawReader().getFormat(), &ErrUnit));