clang-query cache?

Is it possible to cache clang-query results so I don't need to run it for every file in a project evertime?

- Ramin

Well, it depends. If you have certain kinds of queries you want to repeat, there are projects like kythe [1]. Otherwise, clang-query allows you to match the whole AST, so I’m not sure what you’d want to cache. Do you want to cache sub-queries that do not change?

[1] https://github.com/google/kythe

No, I am not asking about individual sub-queries. When I run the whole program from the command line, it can take a long time to run until you can type subqueries.

I never tried multiple files at a time but that should take even linger.

So can I not keep clang-query’s internal data structure so that I can just run subqueries even after restarting the computer, and with out running the whole command from scratch?

R.

If I understand correctly he wants to run it over entire codebase as opposed to feed each file individually.

So, that would mean storing ASTs on disk and then loading them instead of parsing the files. That would sound like a reasonable enough feature to implement, if somebody is up for it.

Correct. I want the AST to be stored on disk.

I am not as familiar with the datastructure but if the classes provide a means of serialzsing and deserializing then I would imagine I can get it done in a couple weeks myself?

Is there any such functionality in the node classes?

R.

Yes, have a look at ASTReader and ASTWriter.

Hey

I’ve tried and it works really well actually OutlookEmoji-😊.png

You can pass many source files to clang-query and it takes a while the first time to parse and build the AST.

But once it’s saved the AST, the next time you can get to clang-query prompt almost instantly which is what I wanted.

I never submitted any patches so will do this as my first one in the next few days.

Any suggestions on what command line option to add to clang-query? May be “–save-ast” or something similar?

-Ramin

+pcc

Hey

I’ve tried and it works really well actually OutlookEmoji-😊.png

You can pass many source files to clang-query and it takes a while the first time to parse and build the AST.

But once it’s saved the AST, the next time you can get to clang-query prompt almost instantly which is what I wanted.

I never submitted any patches so will do this as my first one in the next few days.

Cool!

Any suggestions on what command line option to add to clang-query? May be “–save-ast” or something similar?

We can bikeshed that on the code review :slight_smile: