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

Manuel Klimek klimek at google.com
Tue Apr 28 11:12:35 PDT 2015


On Tue, Apr 28, 2015 at 5:57 PM mats petersson <mats at planetcatfish.com>
wrote:

> 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).
>

Note that -ast-dump is not meant to be used for anything but fancy output,
and does not contain all information of the AST.


>
> 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
>>
>>
> _______________________________________________
> 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/74b6b6a9/attachment.html>


More information about the cfe-dev mailing list