Skip to content

clang-query returns results for invalid queries #54707

Open
@theuni

Description

@theuni

Thanks to @AaronBallman on IRC for helping me understand the actual problem here.

In some cases when presented with a bogus query, clang-query not only fails to detect it, but it responds with bogus matches.

Simplified test-case:

int testfunc(int)
{
    return 0;
}

void caller()
{
    using functype = int(*)(int);
    functype fpointer = testfunc;
    fpointer(1);
    return;
}
clang-query> m  invocation(functionDecl(returns(asString("void"))))

Match #1:

/home/cory/dev/bitcoin-tidy/build/../example2.cc:10:5: note: "root" binds here
    fpointer(1);
    ^~~~~~~~~~~
1 match.

Rather than complaining about invocation being incompatible with functionDecl as it apparently should (thanks @AaronBallman!), a match is returned.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions