forked from OSchip/llvm-project
[clangd] Skip function bodies when building the preamble
Summary: To make building preambles faster and keep them smaller. Reviewers: sammccall Reviewed By: sammccall Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D41495 llvm-svn: 321521
This commit is contained in:
parent
95f0d3286b
commit
da8daa3fe8
|
@ -529,12 +529,22 @@ CppFile::deferRebuild(StringRef NewContents,
|
||||||
IntrusiveRefCntPtr<DiagnosticsEngine> PreambleDiagsEngine =
|
IntrusiveRefCntPtr<DiagnosticsEngine> PreambleDiagsEngine =
|
||||||
CompilerInstance::createDiagnostics(
|
CompilerInstance::createDiagnostics(
|
||||||
&CI->getDiagnosticOpts(), &PreambleDiagnosticsConsumer, false);
|
&CI->getDiagnosticOpts(), &PreambleDiagnosticsConsumer, false);
|
||||||
|
|
||||||
|
// Skip function bodies when building the preamble to speed up building
|
||||||
|
// the preamble and make it smaller.
|
||||||
|
assert(!CI->getFrontendOpts().SkipFunctionBodies);
|
||||||
|
CI->getFrontendOpts().SkipFunctionBodies = true;
|
||||||
|
|
||||||
CppFilePreambleCallbacks SerializedDeclsCollector;
|
CppFilePreambleCallbacks SerializedDeclsCollector;
|
||||||
auto BuiltPreamble = PrecompiledPreamble::Build(
|
auto BuiltPreamble = PrecompiledPreamble::Build(
|
||||||
*CI, ContentsBuffer.get(), Bounds, *PreambleDiagsEngine, VFS, PCHs,
|
*CI, ContentsBuffer.get(), Bounds, *PreambleDiagsEngine, VFS, PCHs,
|
||||||
/*StoreInMemory=*/That->StorePreamblesInMemory,
|
/*StoreInMemory=*/That->StorePreamblesInMemory,
|
||||||
SerializedDeclsCollector);
|
SerializedDeclsCollector);
|
||||||
|
|
||||||
|
// When building the AST for the main file, we do want the function
|
||||||
|
// bodies.
|
||||||
|
CI->getFrontendOpts().SkipFunctionBodies = false;
|
||||||
|
|
||||||
if (BuiltPreamble) {
|
if (BuiltPreamble) {
|
||||||
log(Ctx, "Built preamble of size " + Twine(BuiltPreamble->getSize()) +
|
log(Ctx, "Built preamble of size " + Twine(BuiltPreamble->getSize()) +
|
||||||
" for file " + Twine(That->FileName));
|
" for file " + Twine(That->FileName));
|
||||||
|
|
Loading…
Reference in New Issue