[cfe-dev] extending clang C-API (CIndex)

Sebastien Binet sebastien.binet at cern.ch
Fri Jun 11 12:24:50 PDT 2010


hi there,

I am about to work on extending the C-API provided by CIndex and friends
so I can introspect the AST and (especially) all the xyzDecl (from
python-ctypes.)

not everything can be readily exposed but, for what is easy to do, I was
thinking of exposing the methods of the Decls like so:

/*
 * \brief Whether this class has a definition
 */
CINDEX_LINKAGE unsigned clang_CXXRecordDecl_hasDefinition(CXCursor C);

unsigned clang_CXXRecordDecl_hasDefinition(CXCursor C) {
  if (!clang_isDeclaration(C.kind))
    return 0;
  CXXRecordDecl *D =
  dyn_cast<CXXRecordDecl>(cxcursor::getCursorDecl(C));
  return (D && D->hasDefinition()) ? 1 : 0;
}


so the convention would be:

clang_[C++class-name]_[method-name]( cursor )


what do you think ?

cheers,
sebastien.

-- 
#########################################
# Dr. Sebastien Binet
# Laboratoire de l'Accelerateur Lineaire
# Universite Paris-Sud XI
# Batiment 200
# 91898 Orsay
#########################################



More information about the cfe-dev mailing list