How could I get the classes hierarchy for large code base

I now want to retrieve all the class hierarchy for large code base software, basically given one class, I would like to know its parents, the parents of the parents till the basic class. I wonder how could I achieve this, do I need to modify the clang? If so, could anyone advise me the related data structure. I also wonder if libclang is a good solution.

If you use cmake, then -DCMAKE_EXPORT_COMPILE_COMMANDS=On gives you a compile_commands.json file. This is often required by LSP servers. clangd supports the type hierarchy extension:


Then you editor of choice may allow you to analyse the type hierarchy.

Thanks for your help, so amazing that clangd integrate such functionality. I wonder if there’s any tutorial/command to query the parents for a class, such. Do we need a small program? It’s my first time to know clangd and still being confused by this set of stuff.

There are many LSP servers:

You are not limited to clangd (clang daemon).
Outside of clangd resp. LSP, I do not know any other way to get the type hierarchy for a codebase.

Thanks for your help, I actually solve this problem by writing a clang plugin.Still good to know I have clangd option for further use.