Treat this as a parameter in IR generation#3571
Conversation
dbartol
left a comment
There was a problem hiding this comment.
Mostly LGTM. A few suggested tweaks.
Does this really not affect any dataflow results (yet)?
| private newtype TAllocation = | ||
| TVariableAllocation(IRVariable var) or | ||
| TIndirectParameterAllocation(IRAutomaticUserVariable var) { | ||
| TIndirectParameterAllocation(IRVariable var) { |
There was a problem hiding this comment.
| TIndirectParameterAllocation(IRVariable var) { | |
| TIndirectParameterAllocation(IRAutomaticVariable var) { |
|
|
||
| class IndirectParameterAllocation extends Allocation, TIndirectParameterAllocation { | ||
| IRAutomaticUserVariable var; | ||
| IRVariable var; |
There was a problem hiding this comment.
| IRVariable var; | |
| IRAutomaticVariable var; |
|
|
||
| newtype TInstructionTag = | ||
| OnlyInstructionTag() or // Single instruction (not including implicit Load) | ||
| InitializeThisAddressTag() or |
There was a problem hiding this comment.
You could probably just reuse the tags we already use when generating other InitializeParameter sequences. Not a big deal either way, though.
|
It does affect one result in dataflow, but this doesn't add the output side. I think it should affect a few more tests, though... |
Apparently the reason we're not getting a lot of dataflow changes is because a setter like this: struct A {
int x; int y;
void set_x(int val) {
this->x = val;
}
};is not getting a void set_x(A* a, int val) {
a->x = val;
}But the IR for the first setter is: and for the second one it's: @rdmarsh2 is that intentional? |
|
Yes. I was planning to add the |
Bring in new tests so their output can be fixed
dbartol
left a comment
There was a problem hiding this comment.
LGTM
Take a quick look at the new consistency failure in fields/dataflow-ir-consistency.expected, but if it's just a dupe of the other two existing failures, feel free to merge.
|
It looks like the same issue as the existing two failures (Chi node associated with a call argument that's a pointer to a field having both the pointer type and an unknown type) |
This stops generating
InitalizeThisinstructions for C++, in favor of treatingthisas a parameter, with correspondingInitializeParameterandInitializeIndirectioninstructions. This makes alias analysis handle thethispointer accurately. C# IR generation is not currently affected.This closes https://github.com/github/codeql-c-analysis-team/issues/50