<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">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>