Skip to content

Commit dd6085f

Browse files
committed
C++/C#: Sync identical files.
1 parent 3da1c2b commit dd6085f

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,20 @@ private predicate operandReturned(Operand operand, IntValue bitOffset) {
266266
bitOffset = Ints::unknown()
267267
}
268268

269+
pragma[nomagic]
270+
private predicate initializeParameterInstructionHasVariable(
271+
IRVariable var, InitializeParameterInstruction init
272+
) {
273+
init.getIRVariable() = var
274+
}
275+
276+
private predicate instructionInitializesThisInFunction(
277+
Language::Function f, InitializeParameterInstruction init
278+
) {
279+
initializeParameterInstructionHasVariable(any(IRThisVariable var), pragma[only_bind_into](init)) and
280+
init.getEnclosingFunction() = f
281+
}
282+
269283
private predicate isArgumentForParameter(
270284
CallInstruction ci, Operand operand, InitializeParameterInstruction init
271285
) {
@@ -275,8 +289,7 @@ private predicate isArgumentForParameter(
275289
(
276290
init.getParameter() = f.getParameter(operand.(PositionalArgumentOperand).getIndex())
277291
or
278-
init.getIRVariable() instanceof IRThisVariable and
279-
unique( | | init.getEnclosingFunction()) = f and
292+
instructionInitializesThisInFunction(f, init) and
280293
operand instanceof ThisArgumentOperand
281294
) and
282295
not Language::isFunctionVirtual(f) and

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,20 @@ private predicate operandReturned(Operand operand, IntValue bitOffset) {
266266
bitOffset = Ints::unknown()
267267
}
268268

269+
pragma[nomagic]
270+
private predicate initializeParameterInstructionHasVariable(
271+
IRVariable var, InitializeParameterInstruction init
272+
) {
273+
init.getIRVariable() = var
274+
}
275+
276+
private predicate instructionInitializesThisInFunction(
277+
Language::Function f, InitializeParameterInstruction init
278+
) {
279+
initializeParameterInstructionHasVariable(any(IRThisVariable var), pragma[only_bind_into](init)) and
280+
init.getEnclosingFunction() = f
281+
}
282+
269283
private predicate isArgumentForParameter(
270284
CallInstruction ci, Operand operand, InitializeParameterInstruction init
271285
) {
@@ -275,8 +289,7 @@ private predicate isArgumentForParameter(
275289
(
276290
init.getParameter() = f.getParameter(operand.(PositionalArgumentOperand).getIndex())
277291
or
278-
init.getIRVariable() instanceof IRThisVariable and
279-
unique( | | init.getEnclosingFunction()) = f and
292+
instructionInitializesThisInFunction(f, init) and
280293
operand instanceof ThisArgumentOperand
281294
) and
282295
not Language::isFunctionVirtual(f) and

0 commit comments

Comments
 (0)