<div dir="ltr"><div dir="ltr">On Wed, Nov 10, 2021 at 8:14 AM David Blaikie via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">On Tue, Nov 9, 2021 at 8:38 PM Andrew Tomazos via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">On Tue, Nov 9, 2021 at 7:28 PM Sam McCall via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">On Tue, Nov 9, 2021 at 7:30 PM Demi Marie Obenour <<a href="mailto:demiobenour@gmail.com" target="_blank">demiobenour@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 11/9/21 1:03 PM, Sam McCall wrote:<br>
>> Could an index be persisted to disk, reloaded at startup<br>
> <br>
> (Clangd does have this too, FWIW)<br>
> <br>
> <br>
>> and incrementally changed as the user edits?<br>
> <br>
> User edits mean we need to parse new code.<br>
> Absent a pseudoparser, the only thing that parses code is clang.<br>
> Clang needs a full AST, so this step is slow.<br>
<br>
What I meant is that clang could reparse only the code the user has<br>
edited, rather than reparsing the entire source file from scratch.<br>
I believe rust-analyzer does exactly this for Rust source, and my<br>
understanding is that it is considered fast enough.</blockquote></div></div></blockquote><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div>Yes, you could do this, but not with clang as the parser.</div></div></div></blockquote><div><br></div><div>If it were modified to efficiently persist the salient parser state (including partial AST) at checkpoints during translation after every few lines (see <a href="https://en.wikipedia.org/wiki/Persistent_data_structure" target="_blank">https://en.wikipedia.org/wiki/Persistent_data_structure</a>), and then able to serialize that history and reload from a checkpoint just above a modification, then it wouldn't have to start from scratch every time.  Again, I would spend some time thinking about how pre-compiled headers and modules work.</div></div></div></blockquote><div><br>To be clear, the folks making this proposal are pretty closely connected to how PCH and modules work - I think it's fair to assume they've spent quite a while thinking about how these things work and could be applied. </div></div></div></blockquote><div><br></div><div>Yeah, We've been spending years of effort on improving these things (and will continue) and applying them in clangd -- clangd snapshots the initial #includes of the main file (which is called preamble), and uses this preamble to build the AST of the main file (the AST build with an up-to-date/stale preamble is fast).</div><div>However, it doesn't solve all: initial build of preamble can be extremely slow (tens of seconds, or minutes); cross-file refactorings might want to edit an unopened file; there are use cases where it is impractical to have a real compilation environment setup.</div><div>These are the areas we aim to improve with a pseudo parser.</div><div></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div></div>