Skip to content

Commit 9d8052a

Browse files
authored
Merge pull request github#3813 from MathiasVP/is-argument-for-parameter-join-order
C++: Improve join order for AliasAnalysis::isArgumentForParameter
2 parents 8725e09 + 63752dd commit 9d8052a

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/AliasAnalysis.qll

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,16 +196,17 @@ private predicate operandReturned(Operand operand, IntValue bitOffset) {
196196
bitOffset = Ints::unknown()
197197
}
198198

199-
private predicate isArgumentForParameter(CallInstruction ci, Operand operand, Instruction init) {
199+
private predicate isArgumentForParameter(
200+
CallInstruction ci, Operand operand, InitializeParameterInstruction init
201+
) {
200202
exists(Language::Function f |
201203
ci = operand.getUse() and
202204
f = ci.getStaticCallTarget() and
203205
(
204-
init.(InitializeParameterInstruction).getParameter() =
205-
f.getParameter(operand.(PositionalArgumentOperand).getIndex())
206+
init.getParameter() = f.getParameter(operand.(PositionalArgumentOperand).getIndex())
206207
or
207-
init.(InitializeParameterInstruction).getIRVariable() instanceof IRThisVariable and
208-
init.getEnclosingFunction() = f and
208+
init.getIRVariable() instanceof IRThisVariable and
209+
unique( | | init.getEnclosingFunction()) = f and
209210
operand instanceof ThisArgumentOperand
210211
) and
211212
not Language::isFunctionVirtual(f) and

cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/AliasAnalysis.qll

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,16 +196,17 @@ private predicate operandReturned(Operand operand, IntValue bitOffset) {
196196
bitOffset = Ints::unknown()
197197
}
198198

199-
private predicate isArgumentForParameter(CallInstruction ci, Operand operand, Instruction init) {
199+
private predicate isArgumentForParameter(
200+
CallInstruction ci, Operand operand, InitializeParameterInstruction init
201+
) {
200202
exists(Language::Function f |
201203
ci = operand.getUse() and
202204
f = ci.getStaticCallTarget() and
203205
(
204-
init.(InitializeParameterInstruction).getParameter() =
205-
f.getParameter(operand.(PositionalArgumentOperand).getIndex())
206+
init.getParameter() = f.getParameter(operand.(PositionalArgumentOperand).getIndex())
206207
or
207-
init.(InitializeParameterInstruction).getIRVariable() instanceof IRThisVariable and
208-
init.getEnclosingFunction() = f and
208+
init.getIRVariable() instanceof IRThisVariable and
209+
unique( | | init.getEnclosingFunction()) = f and
209210
operand instanceof ThisArgumentOperand
210211
) and
211212
not Language::isFunctionVirtual(f) and

csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/AliasAnalysis.qll

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,16 +196,17 @@ private predicate operandReturned(Operand operand, IntValue bitOffset) {
196196
bitOffset = Ints::unknown()
197197
}
198198

199-
private predicate isArgumentForParameter(CallInstruction ci, Operand operand, Instruction init) {
199+
private predicate isArgumentForParameter(
200+
CallInstruction ci, Operand operand, InitializeParameterInstruction init
201+
) {
200202
exists(Language::Function f |
201203
ci = operand.getUse() and
202204
f = ci.getStaticCallTarget() and
203205
(
204-
init.(InitializeParameterInstruction).getParameter() =
205-
f.getParameter(operand.(PositionalArgumentOperand).getIndex())
206+
init.getParameter() = f.getParameter(operand.(PositionalArgumentOperand).getIndex())
206207
or
207-
init.(InitializeParameterInstruction).getIRVariable() instanceof IRThisVariable and
208-
init.getEnclosingFunction() = f and
208+
init.getIRVariable() instanceof IRThisVariable and
209+
unique( | | init.getEnclosingFunction()) = f and
209210
operand instanceof ThisArgumentOperand
210211
) and
211212
not Language::isFunctionVirtual(f) and

0 commit comments

Comments
 (0)