clangd communicates with an editor via JSON-RPC. It parses JSON with YAMLParser, which is awkward, and generates JSON with printf and friends, which is miserable. Much of LLVM does things this way, but clangd does it a lot.
I’d like to try replacing this with a JSON library. nlohmann/json[1] seems like a reasonable fit: C++11 with exceptions optional, simple build, MIT license.
I’d propose vendoring it under tools/clang/tools/extra/clangd/nlohmann-json so there’s no question of it “leaking” into runtimes as described in this thread[2].
This also means it wouldn’t solve llvm’s general JSON-parser problem
Any LLVM-level objections or concerns? (Whether that library is the right technical choice for clangd can be discussed elsewhere, I think)
If anyone wants to argue that we shouldn’t bury it in clang/tools/extra/clangd, that’s fine too!
Cheers, Sam
[1] https://github.com/nlohmann/json/blob/develop/src/json.hpp
[2] https://groups.google.com/d/msg/llvm-dev/2JHX3smXTpE/U-E32Yg0AAAJ