I'm interested on clang to parse C/C++ code and be able to locate methods and functions.
Is it possible to use clang to parse a C++ source code file and get a collection of classes and methods and where they're located?
You could write a clang plugin, which does this for you.
Take a look at this article. It basically describes how to build your own plugin and use the ASTConsumer to traverse the AST. Like it is written in the article, start from the existing plugin example PrintFunctionNames. The method HandleTopLevelDecl(DeclGroupRef DG)
is invoked for each function declaration. Additionally to ND->getNameAsString()
you could call ND->getLocation()
in this method. Also have a look at the API documentation and this two questions for more information: