[cfe-dev] libclang 3.5 C interface - cannot get to macro	definitions/expansions with cursors
    Matt Stevens via cfe-dev 
    cfe-dev at lists.llvm.org
       
    Mon Nov 30 14:05:34 PST 2015
    
    
  
> On Nov 30, 2015, at 5:52 AM, Juaristi Álamos, Ander via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> 
> Hi all,
> 
> I'm writing a libclang-based C application to get information about
> functions, variables and macros, and should treat them all equally.
> 
> What I need is to be able to parse the macro definitions and expansions
> (before they are expanded), as if they were functions.
> 
> To test libclang, I've written a sample application that walks over the
> AST like this:
> 
>    error = clang_parseTranslationUnit2(index, 0, argv, argc, 0, 0,
>             CXTranslationUnit_None,
>             &tu);
>    if (tu) {
>        cursor = clang_getTranslationUnitCursor(tu);
>        clang_visitChildren(cursor, cx_visit, NULL);
>        ...
Hi AJ,
To visit cursors for macro definitions and expansions pass the CXTranslationUnit_DetailedPreprocessingRecord option to clang_parseTranslationUnit2().
Matt
    
    
More information about the cfe-dev
mailing list