Add hasRetValue narrowing matcher for returnStmt so that you can match on the expression returned by a return stmt (or lack thereof).
Currently you can only match the type of a return value on a functionDecl with returns.
An example:
clanger> cat /tmp/a.cpp
void g() {
return;
}
void f() {
return (void) g();
}
int h() {
return 1;
}
int j() {
return h();
}
bool k() {
return true;
}
~/dev/build
clanger> bin/clang-query /tmp/a.cpp -- -std=c++11
clang-query> match functionDecl(returns(voidType()))
Match #1:
/tmp/a.cpp:1:1: note: "root" binds here
void g() {
^~~~~~~~~~
Match #2:
/tmp/a.cpp:5:1: note: "root" binds here
void f() {
^~~~~~~~~~
2 matches.
clang-query> match returnStmt(unless(hasRetValue(expr())))
Match #1:
/tmp/a.cpp:2:3: note: "root" binds here
return;
^~~~~~
1 match.
clang-query> ^D