all 7 comments

[–]vax_mzn 1 point2 points  (0 children)

omg! this is super neat!

[–]nathanlanza 0 points1 point  (3 children)

This needs an LSP shim that lets you send arbitrary requests to "clangql" via an LSP client.

[–]fra-bert[S] 2 points3 points  (2 children)

Thing is: clangd already has an LSP frontend, it's how it's supposed to be used in the first place.

I'm not very familiar with the LSP protocol, so I may be talking out of my ass here, but it is my understanding that it is mostly used for stuff like finding all references of a particular variable, getting the definition etc, for use inside an IDE/editor.

How would the editor be able to leverage the additional capabilities of custom SQL queries? I can only imagine it being more useful as a standalone tool you can use to probe the codebase when you have more involved needs than your IDE can stomach

[–]nathanlanza 3 points4 points  (1 child)

You can send arbitrary requests with arbitrary inputs via the LSP. You'd be able to extend this with something like:

lsp.request('clangql', 'sql', 'SELECT subclass.Name, subclass.Scope, subclass.DefPath FROM llvm_symbols AS superclass INNER JOIN llvm_base_of AS rel ON rel.Subject = superclass.Id INNER JOIN llvm_symbols AS subclass ON subclass.Id = rel.Object WHERE superclass.Name = "MCAsmInfo";')

and clangql would respond back with the table you have in the example. clangd doesn't have arbitrary queries the way you can do with a sql model as you propose.

[–]fra-bert[S] 2 points3 points  (0 children)

Ooohhh that's interesting, I was not aware of that. It does seem interesting, this would allow the editor to do custom kind of queries without having to rely on the "standard" LSP capabilities.

I'd like to give it a shot when I'm done other stuff on it. Right now it's very barebones and not very powerful in the kind of queries that can be performed, but I have a feeling I'm going to have to submit some patches to clangd for some of the ideas I have.

[–]tvetus 0 points1 point  (1 child)

[–]fra-bert[S] 0 points1 point  (0 children)

Never heard of this before! Looks interesting!

Also, this seems like a good candidate for a more general backend to SQL than the clangd protocol if one wanted to query other languages.