Index: clangd/ClangdUnit.cpp =================================================================== --- clangd/ClangdUnit.cpp +++ clangd/ClangdUnit.cpp @@ -529,12 +529,22 @@ IntrusiveRefCntPtr PreambleDiagsEngine = CompilerInstance::createDiagnostics( &CI->getDiagnosticOpts(), &PreambleDiagnosticsConsumer, false); + + // Skip function bodies when building the preamble to speed up building + // the preamble and make it smaller. CI is later reused to build the AST, + // so we set SkipFunctionBodies back to false after preamble is built. + 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); + // Preamble is built, restore SkipFunctionBodies. + CI->getFrontendOpts().SkipFunctionBodies = false; + if (BuiltPreamble) { log(Ctx, "Built preamble of size " + Twine(BuiltPreamble->getSize()) + " for file " + Twine(That->FileName));