Clang tool: Enable incremental pre-processing

This avoids doing extra work when processing multiple input files.

PiperOrigin-RevId: 539884025
Change-Id: I8e48495f33c09bc53e70f4d5c1d730fe7c1202b2
This commit is contained in:
Christian Blichmann 2023-06-13 01:03:52 -07:00 committed by Copybara-Service
parent f2048d028f
commit 04cb14791e

View File

@ -26,6 +26,7 @@
#include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/CompilerInvocation.h" #include "clang/Frontend/CompilerInvocation.h"
#include "clang/Frontend/FrontendAction.h" #include "clang/Frontend/FrontendAction.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Tooling/Tooling.h" #include "clang/Tooling/Tooling.h"
#include "sandboxed_api/tools/clang_generator/emitter.h" #include "sandboxed_api/tools/clang_generator/emitter.h"
#include "sandboxed_api/tools/clang_generator/types.h" #include "sandboxed_api/tools/clang_generator/types.h"
@ -116,6 +117,11 @@ class GeneratorAction : public clang::ASTFrontendAction {
emitter_, options_); emitter_, options_);
} }
bool BeginSourceFileAction(clang::CompilerInstance& ci) override {
ci.getPreprocessor().enableIncrementalProcessing();
return true;
}
bool hasCodeCompletionSupport() const override { return false; } bool hasCodeCompletionSupport() const override { return false; }
Emitter& emitter_; Emitter& emitter_;