[cfe-dev] looking for a C++ header file parser

mats petersson mats at planetcatfish.com
Tue Apr 28 08:52:57 PDT 2015


You can get the Clang to do this, yes.

Depending on exactly what you need to do with the data, you may be fine to
just (automatically?) produce a file that includes the base-header-file,
and then pass that to `clang -Xclang -ast-dump -fsyntax-only
yourfile-here.c`, and capture that output (perhaps with
-fno-color-diagnostics to make it more machine readable) - along with some
post-processing (e.g. some shell script or python code to parse that).

Otherwise, you will need to use clang and it's tool helpers as a library
and build a small C++ program that invokes clang and retrieves the AST as a
data-structure, and then work on that (again, depends on exactly what you
want to achieve).

--
Mats

On 28 April 2015 at 16:26, Brian Hare <bhare8972 at hotmail.com> wrote:

>
> I am looking for some package that can parse C++ header files (hopefully
> recursively), and return a structure that holds all the available name
> information, classes, structs, namespaces, global variables, types, macros,
> functions, ect...
>
> Is there a way to use Clang to do this?
>
> Thanks!
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150428/5b37e330/attachment.html>


More information about the cfe-dev mailing list