[cfe-dev] walking macros with clang-c

Daniel Herring dherring at tentpost.com
Wed May 11 18:23:50 PDT 2011


Hi,

I am trying to use clang-c/Index.h to analyze header files.  I can access 
most things of interest, but macro definitions appear to be completely 
opaque.

Is there a clang-c equivalent of the MacroInfo class?
http://clang.llvm.org/doxygen/classclang_1_1MacroInfo.html

In particular, I want to know isFunctionLike/isObjectLike and to access 
the argument and token lists.  Variadic and builtin information would be 
nice but not necessary at the moment.

Here are two example macros that I'd like to parse.  They are from 
H5Tpublic.h in the HDF5 library.

#define H5OPEN          H5open(),
...
#define H5T_IEEE_F32BE              (H5OPEN H5T_IEEE_F32BE_g)

Thanks,
Daniel

P.S.  If the answer is "help wanted, shouldn't be hard to add", please 
direct me to the relevant source files.  Otherwise, I can stick with my 
existing hodge-podge of sed scripts for macros.



More information about the cfe-dev mailing list