I am using python binding for Libclangs. I have basically two queries:
I want to know how we can analyze a library function that is not user defined and for which the library was not included. E.g. when I have the following source code -
char* a=(char *)malloc(4);
- Libclang cannot parse malloc () since no stdlib has been included in this code and does not have a user-defined definition for malloc.
An object that is not defined using the constructor is not recognized by the Libclangs AST. For example, in the source code -
vector<int> color; color.push_back(1); color.push_back(2);
push_back () statements will not be parsed, but when writing:
vector<int> color=new vector<int>(); color.push_back(1); color.push_back(2);
he analyzes correctly.
Another unexpected manifestation of this behavior is that such objects are passed as functional parameters to a user-defined function. For example,
bool check(int **grid, vector<char> color){ color.push_back('a'); }
push_back () is still not identified, but when it is written, everything is parsed correctly
bool check(int **grid, vector<char> color, int anc, int cur){ vector<char> color = new vector<int>() color.push_back('a');
It would be great if someone could suggest a workaround. Perhaps this is a flag that, when set, can avoid this?
c ++ python parsing clang libclang
user3848619
source share