[cfe-dev] Determine CUDA qualifiers in AST

Felix Schmitt felix.schmitt at zih.tu-dresden.de
Wed Jun 15 03:54:32 PDT 2011


Hi everbody,

I am currently working on CUDA source-to-source transformations using clang
version 3.0 (trunk 132310).

I understand from the sources that there is support for CUDA qualifiers such as
__global__, __shared__ etc. However, I don't know how to find out for example
which functions have the __global__ qualifiers attached.

I am currently using an ASTConsumer to traverse the functions and statements:

...
for (DeclContext::decl_iterator
            D = C.getTranslationUnitDecl()->decls_begin(),
                DEnd = C.getTranslationUnitDecl()->decls_end();
                D != DEnd;
                ++D)
{
            FunctionDecl *FD;
            Stmt *Body = FD->getBody();

            ...
for (Stmt::child_iterator stmt = Body->child_begin(); stmt != Body->child_end();
stmt++) {...}
}
...

Could anyone please tell me which methods to use to extract this information
(or is there a better way than mine to achieve this?) ?

Thanks a lot
Felix








More information about the cfe-dev mailing list