Код: Выделить всё
#include
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();
}
< /code>
Если я выполняю следующую команду на ней, < /p>
clang-query -c "match expr(
anyOf(
unaryOperator(
hasOperatorName(\"*\")
),
unaryOperator(
hasOperatorName(\"->\")
),
cxxOperatorCallExpr(
hasOverloadedOperatorName(\"*\")
),
cxxOperatorCallExpr(
hasOverloadedOperatorName(\"->\")
)
), isExpansionInMainFile()
)" debugging.cpp | less
< /code>
Я получаю выход, который заканчивается, как это (я отфильтровал все совпадения, происходящие в включенных заголовках): < /p>
/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.
Что я делаю не так? < /p>
Подробнее здесь: https://stackoverflow.com/questions/794 ... tin-usages