Dumping JSON from index stores for sourcekit-lsp

I've been looking at index stores for some large iOS apps, and I see there's a really helpful option in Swift's LLVM c-index-test for dumping JSON from index stores.

$ c-index-test core -aggregate-json /path/to/index/store

However, this doesn't always output valid JSON. It looks like JSON dumper assumes that function names never contain ", which isn't true for C++ code with user-defined literals.

Can anyone suggest a workaround?

I've also opened a PR [c-index-test] Fix JSON string quoting by Wilfred · Pull Request #9864 · swiftlang/llvm-project · GitHub which I think fixes this, if anyone could take a look.

Thanks for the PR, @Wilfred. I can’t think of a workaround right now other than using some kind of knowledge about your code base to find the malformed JSON and correct it after dumping them.

1 Like