Can I get clang.cindex.CursorKind.CALL_EXPR cursor argument values ?
When I reset AST using the compiler (clang ++ -ast-dump source.cpp), I get information about function calls (call expressions) and their arguments. But I cannot replicate it using bindings for python (where the AST is retrieved using the libclang parser).
The source code is used here:
#include <iostream> #include <GL/glut.h> #include <EGL/egl.h> #define MULTILINE(...) #__VA_ARGS__ void renderFunction() { glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0, 0.0, 1.0); glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); glBegin(GL_QUADS); glVertex2f(-0.5, -0.5); glVertex2f(-0.5, 0.5); glVertex2f(0.5, 0.5); glVertex2f(0.5, -0.5); glEnd(); glFlush(); } int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE); glutInitWindowSize(500,500); glutInitWindowPosition(100,100); glutCreateWindow("OpenGL - First window demo"); glutDisplayFunc(renderFunction); glutMainLoop(); return 0; }
Here is part of his AST dump:
| |-CallExpr 0x430b540 <line:10:5, col:32> 'void' | | |-ImplicitCastExpr 0x430b528 <col:5> 'void (*)(GLbitfield)' <FunctionToPointerDecay> | | | `-DeclRefExpr 0x430b4d0 <col:5> 'void (GLbitfield)' lvalue Function 0x3d3b060 'glClear' 'void (GLbitfield)' | | `-ImplicitCastExpr 0x430b570 </usr/include/GL/gl.h:691:31> 'GLbitfield':'unsigned int' <IntegralCast> | | `-IntegerLiteral 0x430b4b0 <col:31> 'int' 16384
I would like to get part of the IntegerLiteral value in the last line by evaluating the call expression cursor.
source share