我正在使用 clang ASTMatcher 来查找我的源代码中定义 isnan 的位置。我试图理解为什么有三个匹配项,尽管我限制只在主文件中匹配。请在下面找到示例源代码:
#include <math.h>
int main()
{
if(isnan(0.0)){
}
}
当我进行 clang-query match 时,我得到以下输出:
clang-query> match declRefExpr(isExpansionInMainFile())
Match #1:
/home/clang-llvm/code/test.cpp:6:5: note: "root" binds here
if(isnan(0.0)){
^~~~~~~~~~
/usr/include/math.h:299:9: note: expanded from macro 'isnan'
? __isnanf (x) \
^~~~~~~~
Match #2:
/home/clang-llvm/code/test.cpp:6:5: note: "root" binds here
if(isnan(0.0)){
^~~~~~~~~~
/usr/include/math.h:301:9: note: expanded from macro 'isnan'
? __isnan (x) : __isnanl (x))
^~~~~~~
Match #3:
/home/clang-llvm/code/test.cpp:6:5: note: "root" binds here
if(isnan(0.0)){
^~~~~~~~~~
/usr/include/math.h:301:23: note: expanded from macro 'isnan'
? __isnan (x) : __isnanl (x))
^~~~~~~~
3 matches.
无论如何限制匹配只针对源代码而不是宏?
我将不胜感激任何帮助。