C++: add MemberFunction::getTypeOfThis()#3814
Conversation
Co-authored-by: Dave Bartolomeo <dbartol@github.com>
|
I just tested the upgrade script on a Chromium database, and it was not particularly fast, maybe somewhere around 40 seconds. |
dbartol
left a comment
There was a problem hiding this comment.
LGTM, but some tests are still failing
|
The tests on this PR fail because they don't run with the updated extractor. They pass on the internal/extractor PR - we should wait for Ian/Matt to review that and merge the two PRs at the same time. |
| } | ||
|
|
||
| /** | ||
| * Gets the type of the `this` parameter associated with this member function, if any. |
There was a problem hiding this comment.
It might be nice to spell out how this is different from getDeclaringType(), i.e. being a pointer and, I can see from the test, potential for const and volatile specifiers.
There was a problem hiding this comment.
I've updated the comment, but this raises an interesting question.
The member_function_this_type and the extractor allow, in principle, for any kind of Type. In practice, it's always going to be a PointerType. We could consider changing the return type of this predicate.
There was a problem hiding this comment.
Changing to PointerType sounds good to me.
| void f() { | ||
| global++; | ||
| } | ||
| }; |
There was a problem hiding this comment.
Might be worth adding a couple of template classes, one that gets instantiated and one that doesn't, too.
There was a problem hiding this comment.
I've added that. For the instantiated one, we get results for both the instantiation and the template. For the uninstantiated one, we get no results.
| @@ -0,0 +1,6 @@ | |||
| import cpp | |||
|
|
|||
| query predicate thisExprType(ThisExpr e, Type t) { t = e.getType() } | |||
There was a problem hiding this comment.
Is thisExprType needed?
There was a problem hiding this comment.
There didn't seem to be any existing tests for ThisExpr, so I thought it prudent to add it as well.
matt-gretton-dann
left a comment
There was a problem hiding this comment.
Following conversation is Slack re @jbj being happy for the type change being a follow-up - approving.
member_function_this_typeto the dbscheme (there's a corresponding extractor PR to populate this).MemberFunction::getTypeOfThis()predicatethiswas not previously in the database.Closes https://github.com/github/codeql-c-extractor-team/issues/71