I am unable to parse the body of a namespace function in c++ with libclang.
I have a class in a namespace like so:
namespace outer {
namespace inner {
class MyClass {
public:
short myMethod(){
return NTOHS(10);
}
short anotherMethod();
};
short MyClass::anotherMethod(){
return NTOHS(11);
}
short myFunction(){
return NTOHS(12);
}
}
}
Using a python wrapper for libclang, I can find each node through recursion:
def find_node(node):
print node # Just print stuff about the node (spelling, location, etc.)
for child in node.get_children():
find_node(child)
I am able to detect the usage of NTOHS in myMethod
and myFunction
and print information about those nodes, but am unable to detect it in MyClass::anotherMethod
.
Someone else ran into a similar problem, but it doesn't seem to have been answered.
NTOHS here is just the linux/unix command for converting network to host order.
How can I use libclang to detect NTOHS in the namespace function?