[clang] Add BeforeExecute method to PrecompiledPreamble

Summary: Adds BeforeExecute method to PrecompiledPreamble to be called
before Execute(). This method can be overriden.

Patch by William Enright.

Reviewers: malaperle, ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: arphaman, cfe-commits, ilya-biryukov

Differential Revision: https://reviews.llvm.org/D41365

llvm-svn: 321189
This commit is contained in:
Ilya Biryukov 2017-12-20 16:48:56 +00:00
parent 7d661bb248
commit 1f8647d1c1
2 changed files with 6 additions and 0 deletions

View File

@ -244,6 +244,10 @@ class PreambleCallbacks {
public:
virtual ~PreambleCallbacks() = default;
/// Called before FrontendAction::BeginSourceFile.
/// Can be used to store references to various CompilerInstance fields
/// (e.g. SourceManager) that may be interesting to the consumers of other callbacks.
virtual void BeforeExecute(CompilerInstance &CI);
/// Called after FrontendAction::Execute(), but before
/// FrontendAction::EndSourceFile(). Can be used to transfer ownership of
/// various CompilerInstance fields before they are destroyed.

View File

@ -333,6 +333,7 @@ llvm::ErrorOr<PrecompiledPreamble> PrecompiledPreamble::Build(
std::unique_ptr<PrecompilePreambleAction> Act;
Act.reset(new PrecompilePreambleAction(
StoreInMemory ? &Storage.asMemory().Data : nullptr, Callbacks));
Callbacks.BeforeExecute(*Clang);
if (!Act->BeginSourceFile(*Clang.get(), Clang->getFrontendOpts().Inputs[0]))
return BuildPreambleError::BeginSourceFileFailed;
@ -694,6 +695,7 @@ void PrecompiledPreamble::setupPreambleStorage(
}
}
void PreambleCallbacks::BeforeExecute(CompilerInstance &CI) {}
void PreambleCallbacks::AfterExecute(CompilerInstance &CI) {}
void PreambleCallbacks::AfterPCHEmitted(ASTWriter &Writer) {}
void PreambleCallbacks::HandleTopLevelDecl(DeclGroupRef DG) {}