D18551: clang: Create preamble only on second parse

Milian Wolff noreply at phabricator.kde.org
Sun Feb 10 21:18:46 GMT 2019

mwolff added a comment.

  In D18551#403490 <https://phabricator.kde.org/D18551#403490>, @aaronpuchert wrote:
  > I'm fine with that, but would prefer never having it. Not all files that are opened will be edited, and the delay caused by creating the preamble after the first edit is probably negligible over the lifetime of a session. It would also allow us to just drop affected preambles when a header is edited — otherwise we might have to recreate all preambles that include the header.
  Hm yes and no. Yes, many files you open due to browsing won't be edited. But once you do, performance is imo quite important. See e.g. `ClangSupport::documentActivated` which has explicit code to attach the AST cf. `AttachASTWithoutUpdating`. The AST is essentially the Clang TU representation. Without that, we can't do code completion at all. Now, imagine we open a C++ file, we realize we don't have the AST, so we trigger a parse to attach the AST. Now you do code completion. When we didn't create the preamble, we will have to reparse the file completely. And this can easily take 1-2s per file, which is *really* annoying. Also note how we just reparsed the file solely for code completion purposes!
  So I really am opposed to the idea of never passing `CXTranslationUnit_CreatePreambleOnFirstParse`. Please, do create the preamble when we have the TU main file or its header file open in the editor.

  R32 KDevelop


To: aaronpuchert, #kdevelop, mwolff, brauch, rjvbb
Cc: rjvbb, kdevelop-devel, gennad, glebaccon, antismap, iodelay, geetamc, Pilzschaf, akshaydeo, surgenight, arrowd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20190210/700292d5/attachment.html>

More information about the KDevelop-devel mailing list