summaryrefslogtreecommitdiff
path: root/clang-tools-extra/clangd/ClangdUnit.cpp
diff options
context:
space:
mode:
authorIlya Biryukov <ibiryukov@google.com>2017-12-28 13:10:15 +0000
committerIlya Biryukov <ibiryukov@google.com>2017-12-28 13:10:15 +0000
commit77b8834b2173efe8f25753ab7e83c49f126b0959 (patch)
tree249b9e78da2a8156222a9b378ed7953e1ef1992e /clang-tools-extra/clangd/ClangdUnit.cpp
parent485ede19e15e35e35afdc323d534dad19358d37a (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
Diffstat (limited to 'clang-tools-extra/clangd/ClangdUnit.cpp')
-rw-r--r--clang-tools-extra/clangd/ClangdUnit.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang-tools-extra/clangd/ClangdUnit.cpp b/clang-tools-extra/clangd/ClangdUnit.cpp
index 5fa8cd33a9b..82ca109d2a5 100644
--- a/clang-tools-extra/clangd/ClangdUnit.cpp
+++ b/clang-tools-extra/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));