I am using Libclang’s python binding. I have basically two queries:
I want to know how can we parse library function which are neither defined by user nor f
You need to add the following argument
-x c++ -std=c++11
when calling parse, otherwise it defaults to parsing C code for .h files. You might rename the header file to .hpp
Here is what my helper script looks like.
from cindex import *
def get_cursor_from_file(filename,my_args=[]):
index = Index.create()
options = TranslationUnit.PARSE_DETAILED_PROCESSING_RECORD
file_obj = index.parse(filename,args=my_args,options=options)
for i in file_obj.diagnostics:
print i
return file_obj.cursor
x = get_cursor_from_file('test.cpp')
for c in x.get_children():
print c.spelling
The source file I tested on looks like this
#include <vector>
using namespace std;
int main(){
char* a=(char *)malloc(4);
vector<int> color;
vector<int> *color2=new vector<int>();
color.push_back(1);
color.push_back(2);
}
bool check(int **grid, vector<char> color){
color.push_back('a');
}