[cfe-dev] [RFC] A C++ pseudo parser for tooling

Andrew Tomazos via cfe-dev cfe-dev at lists.llvm.org
Tue Nov 9 20:38:00 PST 2021


On Tue, Nov 9, 2021 at 7:28 PM Sam McCall via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> On Tue, Nov 9, 2021 at 7:30 PM Demi Marie Obenour <demiobenour at gmail.com>
> wrote:
>
>> On 11/9/21 1:03 PM, Sam McCall wrote:
>> >> Could an index be persisted to disk, reloaded at startup
>> >
>> > (Clangd does have this too, FWIW)
>> >
>> >
>> >> and incrementally changed as the user edits?
>> >
>> > User edits mean we need to parse new code.
>> > Absent a pseudoparser, the only thing that parses code is clang.
>> > Clang needs a full AST, so this step is slow.
>>
>> What I meant is that clang could reparse only the code the user has
>> edited, rather than reparsing the entire source file from scratch.
>> I believe rust-analyzer does exactly this for Rust source, and my
>> understanding is that it is considered fast enough.
>
>

> Yes, you could do this, but not with clang as the parser.
>

If it were modified to efficiently persist the salient parser state
(including partial AST) at checkpoints during translation after every few
lines (see https://en.wikipedia.org/wiki/Persistent_data_structure), 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20211110/8848ab12/attachment.html>


More information about the cfe-dev mailing list