-
Notifications
You must be signed in to change notification settings - Fork 1.8k
C++: add MemberFunction::getTypeOfThis() #3814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. A couple minor suggestions.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
@@ -70,6 +70,13 @@ class MemberFunction extends Function { | |||
result = getADeclarationEntry() and result != getDefinition() | |||
) | |||
} | |||
|
|||
/** | |||
* Gets the type of the `this` parameter associated with this member function, if any. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing to PointerType
sounds good to me.
void f() { | ||
global++; | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is thisExprType
needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There didn't seem to be any existing tests for ThisExpr
, so I thought it prudent to add it as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following conversation is Slack re @jbj being happy for the type change being a follow-up - approving.
member_function_this_type
to the dbscheme (there's a corresponding extractor PR to populate this).MemberFunction::getTypeOfThis()
predicatethis
was not previously in the database.Closes https://github.com/github/codeql-c-extractor-team/issues/71