[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:
Ilya Biryukov 2017-12-28 13:10:15 +00:00
parent 95f0d3286b
commit da8daa3fe8
1 changed files with 10 additions and 0 deletions

View File

@ -529,12 +529,22 @@ CppFile::deferRebuild(StringRef NewContents,
IntrusiveRefCntPtr<DiagnosticsEngine> PreambleDiagsEngine =
CompilerInstance::createDiagnostics(
&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;
auto BuiltPreamble = PrecompiledPreamble::Build(
*CI, ContentsBuffer.get(), Bounds, *PreambleDiagsEngine, VFS, PCHs,
/*StoreInMemory=*/That->StorePreamblesInMemory,
SerializedDeclsCollector);
// When building the AST for the main file, we do want the function
// bodies.
CI->getFrontendOpts().SkipFunctionBodies = false;
if (BuiltPreamble) {
log(Ctx, "Built preamble of size " + Twine(BuiltPreamble->getSize()) +
" for file " + Twine(That->FileName));