问题描述
我正在使用libclang解析.cpp
并获取文件中的所有函数调用。
但是,唯一返回的函数调用是在已解析的 .h
/ .cpp
文件中定义的函数调用,而不是包含文件中的所有函数调用。
例如我正在解析example.cpp
,其中包括
#include "a.h"
#include "example.h"
将检测到对example.h中定义/声明的所有函数的调用,但会跳过a.h中定义的所有函数的调用。 我如何才能检测到它们两者?
在a.h
foo ();
在example.hpp
boo();
在example.cpp
foo();
boo();
仅将boo()
检测为函数调用。它不会在所有标头中递归地检查函数调用。如何强制执行此检查?
CXChildVisitResult functionVisitor(CXCursor cursor){
CXCursorKind cursorKind = clang_getCursorKind(cursor);
CXString cursorSpelling = clang_getCursorSpelling(cursor);
if (cursorKind == CXCursor_CallExpr) {
CXString cursorUsr = clang_getCursorUSR(cursor);
print_function_prototype(cursor);
clang_disposeString(cursorUsr);
}
return CXChildVisit_Continue;
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)