So, here is one solution, although it is not great, but it can help others. CXCursor is a structure that looks like this:
typedef struct { enum CXCursorKind kind; int xdata; const void *data[3]; } CXCursor;
Currently, void * [3] data is mapped to {const clang :: Decl * Parent, const clang :: Stmt * S, CXTranslationUnit TU}. Knowing this, we can write code that extracts C ++ internal clang objects from C libclang state:
#include "clang/AST/Decl.h" bool isScoped=false; { using namespace clang; const Decl *D = static_cast<const Decl *>(cursor.data[0]); if(const EnumDecl *TD = dyn_cast_or_null<EnumDecl>(D)) { isScoped=TD->isScoped(); } }
Many bad things can happen to this solution if your clang headers deviate from your libclang. I don't really care about this solution, but it works.
Niall douglas
source share