[ASTMatcher] builtinType matcher with returns

Piotr Padlewski via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 13 08:51:17 PDT 2016


Hi,

For code like:
namespace boost {
template <typename T, typename C>
T lexical_cast(const C&) {
    return T();
}

}

int g();
long long f(int p);
using namespace boost;
int main() {
    auto s = lexical_cast<int>(5);
    auto p = lexical_cast<int>(6);
    long long z = lexical_cast<long long>(7);
    long long a2 = lexical_cast<long long>("1488");
    long long a3 = lexical_cast<int>("2137");

    g();
    int zda = g();
    f(5);
}

why
does callExpr(hasDeclaration(functionDecl(returns(qualType(asString("long
long")))))) binds to:
    long long z = lexical_cast<long long>(7);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~
(and few others)

but callExpr(hasDeclaration(functionDecl(returns(qualType(builtinType())))))
binds to only calls of non template functions like:

   g();
    ^~~

    int zda = g();
              ^~~

    f(5);
    ^~~~

Is it a bug?

Piotr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160313/06c4ac06/attachment-0001.html>


More information about the cfe-commits mailing list