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

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 22 02:36:09 PST 2017


ilya-biryukov updated this revision to Diff 127995.
ilya-biryukov marked an inline comment as done.
ilya-biryukov added a comment.

- Updated a comment


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41495

Files:
  clangd/ClangdUnit.cpp


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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41495.127995.patch
Type: text/x-patch
Size: 1219 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171222/82166b96/attachment.bin>


More information about the cfe-commits mailing list