A checker (will be uploaded after this patch) needs to check implicit casts. Existing generic matcher "has" ignores implicit casts and parenthesized expressions and no specific matcher for matching return value expression preexisted. The patch adds such a matcher (hasReturnValue).
Details
Diff Detail
Event Timeline
The reason we haven't fixed hasAnyArgument is that it can potentially break its users.
I'd prefer if you separated the fix from the addition.
That way we can revert the fix if needed.
include/clang/ASTMatchers/ASTMatchers.h | ||
---|---|---|
4845 | New matchers must be tested. Also, they should be added to the dynamic registry. | |
4849 | I'm not sure this is needed. |
I will separate it, OK. In the Clang there is one use case that I fixed, although it did not break the tests. Neither of the other "has..." checkers (except the general ones) ignore implicit casts and parenthesized expressions so this one should not do it either because it makes checking implicit casts impossible.
Matcher "hasReturnValue" is needed because "has" ignores all implicit casts and parenthesized expressions and we need to the check implicit casts. I will add a test and add it to the dynamic registry.
I will separate it, OK. In the Clang there is one use case that I fixed, although it did not break the tests. Neither of the other "has..." checkers (except the general ones) ignore implicit casts and parenthesized expressions so this one should not do it either because it makes checking implicit casts impossible.
I agree that we want it, just wanted to point out that it has to be done with care.
Matcher "hasReturnValue" is needed because "has" ignores all implicit casts and parenthesized expressions and we need to the check implicit casts. I will add a test and add it to the dynamic registry.
I see. has() suffers from the same problem. Then it makes sense.
Separation of new matcher and fix for existing matcher. This patch only contains the new matcher. Test added and matcher added to the registry.
I can rerun the script, however it seems it was not executed before the last commit on the master branch, thus if I rerun it then changes will appear in my diff which are not related to my work. What is the exect policy about running this scipt? Should it be rerun before the commit (then it was forgotten by the last committer) or it is executed only before releases?
I don't think there is a specific policy here. We try to keep it up to date, but some changes forget to do it.
We can do it in a separate patch if you feel the extra diff should not be on this one.
a + b (with spaces)
A few in this comment, and one in the test.