如何使用clang libtooling在函数分析期间内置内置/系统函数
问题描述:
我试图使用clang libtooling分析函数。 这里是我想分析的源代码:如何使用clang libtooling在函数分析期间内置内置/系统函数
#include <stdio.h>
int main(){
int a = 100;
printf("a==%d", a);
}
当我跑我的工具,把所有的功能东方电气在上述文件
,我发现有很多内置的/系统的功能,像:
decls:
_IO_cookie_init
__underflow
__uflow
__overflow
_IO_getc
_IO_putc
_IO_feof
_IO_ferror
_IO_peekc_locked
_IO_flockfile
_IO_funlockfile
_IO_ftrylockfile
_IO_vfscanf
_IO_vfprintf
_IO_padn
_IO_sgetn
_IO_seekoff
_IO_seekpos
_IO_free_backup_area
remove
rename
renameat
tmpfile
tmpfile64
tmpnam
tmpnam_r
tempnam
fclose
fflush
fflush_unlocked
fcloseall
fopen
(我认为他们是通过头文件“stdio.h中”中介绍)
我的问题是: 我怎样才能从“STDIO摆脱所有这些内置/系统功能.h“文件或其他(系统)头文件?
在此先感谢!
答
当你访问一个函数,检查其位置(startLoc或endLoc)使用SourceManagers API在系统头 'isInSystemHeader(LOC)'
如:
Bool VisitFunctionDecl(FunctionDecl * D)
{
If(sourceManager.isInSystemHeader(D->getLocStart()))
return true;
}
感谢, 与Hemant
+0
谢谢!有用! – ignorer
您的工具是否会查找已定义的函数或刚声明和未定义的函数? – deLta
@deLta谢谢你的回复。目前,我只是寻找由程序员自己创建的函数的decl。 – ignorer
@deLta顺便说一句,获取已定义函数的方法以及获取已声明和未定义函数的方法是不同的?我很好奇。有可能解释一下它吗?谢谢:) – ignorer