Some context
I am not that familiar with libclang. I am just modifying a vim plugin which uses the python bindings to libclang.
There is a python function which receives a cursor parameter. This is called for almost every node in the AST of the current C++ buffer.
The problem
cursor.kind
is used to get the kind of the cursor. All is ok, except that
- templated free function declarations,
- templated constructor declarations and
- templated method declarations
all have the same kind: FUNCTION_TEMPLATE
. I need to differentiate between them.
More insight
For instance, the non-templated versions of the above have the kinds:
FUNCTION_DECL
CXX_METHOD
andCONSTRUCTOR
.
I have search the source of cindex.py and there are no CXX_METHOD_TEMPLATE
or CONSTRUCTOR_TEMPLATE
or similar.
I have tried without success to somehow get the information I need, e.g. with cursor.get_definition()
and cursor.underlying_typedef_type.get_declaration()
.
The only partial success I got is that for a method and a constructor the semantic and lexical parent is a STRUCT_DECL
.
I don't really care if it's templated or not. All I care if it's a constructor, member or free function.
To sum it up
Given a cursor, how I can tell if it's a method (even templated), a constructor (even templated) or a free function declaration?