Skip to content
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

C++: Use an IPA type rather than negative indexes for argument/parameter matching in data flow #7541

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

@rdmarsh2
Copy link
Contributor

@rdmarsh2 rdmarsh2 commented Jan 7, 2022

No description provided.

@rdmarsh2 rdmarsh2 requested a review from as a code owner Jan 7, 2022
@rdmarsh2 rdmarsh2 requested a review from MathiasVP Jan 7, 2022
@github-actions github-actions bot added the C++ label Jan 7, 2022
rdmarsh2 added 2 commits Jan 7, 2022
This takes advantage of the new ArgumentPosition and ParameterPosition
types in the shared DataFlow library interface to represent indirections
with an IPA type rather than the negative-index system in use previously
@rdmarsh2 rdmarsh2 force-pushed the rdmarsh2/dataflow-ipa-params branch from 0aaac5a to a126154 Jan 7, 2022
Copy link
Contributor

@MathiasVP MathiasVP left a comment

Only a couple of minor comments. I think we should run a DCA for this as well before we merge it.

@@ -11,6 +11,7 @@ private import semmle.code.cpp.ir.IR
private import semmle.code.cpp.controlflow.IRGuards
private import semmle.code.cpp.models.interfaces.DataFlow
private import DataFlowPrivate
private import DataFlowDispatch
Copy link
Contributor

@MathiasVP MathiasVP Jan 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to import DataFlowDispatch here?

Copy link
Contributor Author

@rdmarsh2 rdmarsh2 Jan 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I added that before moving the ArgumentPosition definitions out of DataFlowDispatch. It's not needed any more.

/** An argument position represented by an integer. */
class ArgumentPosition = Position;

class Position extends TPosition {
Copy link
Contributor

@MathiasVP MathiasVP Jan 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add an INTERNAL: Do not use QLDoc to this?

Copy link
Contributor Author

@rdmarsh2 rdmarsh2 Jan 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, but I think I can move it to DataFlowPrivate, actually.

}

newtype TPosition =
TDirectPosition(int index) { exists(any(CallInstruction c).getArgument(index))} or
TIndirectionPosition(int index) { exists(any(CallInstruction c).getArgument(index)) }
Copy link
Contributor

@MathiasVP MathiasVP Jan 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this branch be restricted to those CallInstructions that have a ReadSideEffectInstruction at index index?

Copy link
Contributor Author

@rdmarsh2 rdmarsh2 Jan 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably. I'll just check ReadSideEffectInstruction::getIndex(), though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants