diff options
author | Ilya Biryukov <ibiryukov@google.com> | 2017-12-28 13:10:15 +0000 |
---|---|---|
committer | Ilya Biryukov <ibiryukov@google.com> | 2017-12-28 13:10:15 +0000 |
commit | 4058595ccdcba895adbb791c6d7772036c41e20e (patch) | |
tree | 2777d88bb9e6ee89c17b02c87a6161278fac06e6 | |
parent | 057470116210d2e6bf5e726361e641c8c5de9b35 (diff) |
[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
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@321521 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | clangd/ClangdUnit.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clangd/ClangdUnit.cpp b/clangd/ClangdUnit.cpp index 5fa8cd33..82ca109d 100644 --- a/clangd/ClangdUnit.cpp +++ b/clangd/ClangdUnit.cpp @@ -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)); |