获取此愚蠢的C ++源文件:
#include <optional>
struct Foo {
int hello() const;
};
struct P1 {
P1* another() const;
int give() const;
};
auto fun() {
return std::make_optional(std::make_optional(Foo{}));
}
int main()
{
int * x = new int{3};
P1 * p{};
(*p->another()).another()->another();
p->another()->give();
p->give();
return *x + (*fun())->hello() + p->give();
}
如果我在其上执行以下命令,
clang-query -c "match expr(
anyOf(
unaryOperator(
hasOperatorName(\"*\")
),
unaryOperator(
hasOperatorName(\"->\")
),
cxxOperatorCallExpr(
hasOverloadedOperatorName(\"*\")
),
cxxOperatorCallExpr(
hasOverloadedOperatorName(\"->\")
)
), isExpansionInMainFile()
)" debugging.cpp | less
我得到这样的输出,以这样的结束(我已经过滤了所有在包含标题中发生的匹配):
/home/enrico/debugging.cpp:20:6: note: "root" binds here
20 | (*p->another()).another()->another();
| ^~~~~~~~~~~~~
Match #55:
/home/enrico/debugging.cpp:23:12: note: "root" binds here
23 | return *x + (*fun())->hello() + p->give();
| ^~
Match #56:
/home/enrico/debugging.cpp:23:17: note: "root" binds here
23 | return *x + (*fun())->hello() + p->give();
| ^~~~~~~~~~
Match #57:
/home/enrico/debugging.cpp:23:18: note: "root" binds here
23 | return *x + (*fun())->hello() + p->give();
| ^~~~~~
57 matches.
表明内置
->
尚未匹配,而内置和过载却是匹配的。
我做错了什么?
clang的