[llvm-dev] RFC: Adding a JSON library to LLVM Support

Sam McCall via llvm-dev llvm-dev at lists.llvm.org
Tue Apr 24 03:40:52 PDT 2018


Just pinging this as https://reviews.llvm.org/D45753 is now open.
So if anyone has opinions, that's a good place for them.

(I'm also trying to identify the right reviewer for suitability in
llvm/Support.)

On Mon, Apr 16, 2018 at 4:04 PM Sam McCall <sammccall at google.com> wrote:

> Finally following up here...
>
> We ended up writing a JSON parser and checking it in under clangd/. We've
> been using that for a while now without hitting new problems.
> The header is here:
> https://reviews.llvm.org/source/clang-tools-extra/browse/clang-tools-extra/trunk/clangd/JSONExpr.h
> It's a DOM-based approach with objects on the heap. There's no streaming
> parser, though one could be bolted on for e.g. long arrays. There are some
> weak conventions around marshalling to structs with ADL functions. Compared
> to what was described in my doc, it's simpler but less efficient, dropping
> the arena representation.
>
> (The reasons for not reusing an existing library were covered here:
> https://groups.google.com/forum/#!topic/llvm-dev/5rryBKDY8eY)
>
> There's at least some desire to reuse this more widely (I just talked to
> Pavel about LLDB). So I'd propose lifting this up to llvm/Support/JSON.h.
> (Dependencies are only Support and ADT).
>
> Let me know if anyone has concerns!
>
> On Fri, Oct 27, 2017 at 9:53 PM Sam McCall <sammccall at google.com> wrote:
>
>> We don't have a dedicated JSON library in the LLVM tree, I'd like to add
>> one. The pressing need is for clangd, but we have other tools that
>> read/write JSON too.
>>
>> I'm proposing we write a new one, rather than importing a third-party
>> library (licensing/integration reasons), on or extending YamlParser/YamlIO
>> (usability/flexibility). I lean towards a design that parses a full DOM at
>> once, and provides literal-like syntax for composing documents.
>>
>> I've written a document laying out the reasons for taking this path, and
>> my proposal for a design (with links to a prototype)
>>
>> https://docs.google.com/document/d/1OEF9IauWwNuSigZzvvbjc1cVS1uGHRyGTXaoy3DjqM4/edit
>> (Comments are enabled, but high-level discussion probably belongs on the
>> list instead.)
>>
>> What do you think? I'm particularly interested in which parts of LLVM
>> produce/consume JSON (or might want to), and what they need. I'm mostly
>> familiar with the stuff in clang-tools-extra.
>>
>> Cheers, Sam
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180424/f69be794/attachment.html>


More information about the llvm-dev mailing list