[PATCH] D41495: [clangd] Skip function bodies when building the preamble

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 21 08:11:46 PST 2017

ilya-biryukov created this revision.
ilya-biryukov added a reviewer: sammccall.
Herald added a subscriber: klimek.

To make building preambles faster and keep them smaller.

  rCTE Clang Tools Extra



Index: clangd/ClangdUnit.cpp
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -529,12 +529,22 @@
       IntrusiveRefCntPtr<DiagnosticsEngine> PreambleDiagsEngine =
               &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,
+      // 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));

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41495.127891.patch
Type: text/x-patch
Size: 1298 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171221/b435ec6d/attachment.bin>

More information about the cfe-commits mailing list