Skip to content

Commit 01a9531

Browse files
author
Dave Bartolomeo
committed
C++: Add Instruction::getAParameterSideEffect().
1 parent 5c2bf68 commit 01a9531

File tree

5 files changed

+65
-0
lines changed

5 files changed

+65
-0
lines changed

cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,6 +1645,19 @@ class CallInstruction extends Instruction {
16451645
* Gets the number of arguments of the call, including the `this` pointer, if any.
16461646
*/
16471647
final int getNumberOfArguments() { result = count(this.getAnArgumentOperand()) }
1648+
1649+
/**
1650+
* Holds if the result is a side effect for the argument at the specified index, or `this` if
1651+
* `index` is `-1`.
1652+
*
1653+
* This helper predicate makes it easy to join on both of these columns at once, avoiding
1654+
* pathological join orders in case the argument index should get joined first.
1655+
*/
1656+
pragma[noinline]
1657+
final SideEffectInstruction getAParameterSideEffect(int index) {
1658+
this = result.getPrimaryInstruction() and
1659+
index = result.(IndexedInstruction).getIndex()
1660+
}
16481661
}
16491662

16501663
/**

cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Instruction.qll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,6 +1645,19 @@ class CallInstruction extends Instruction {
16451645
* Gets the number of arguments of the call, including the `this` pointer, if any.
16461646
*/
16471647
final int getNumberOfArguments() { result = count(this.getAnArgumentOperand()) }
1648+
1649+
/**
1650+
* Holds if the result is a side effect for the argument at the specified index, or `this` if
1651+
* `index` is `-1`.
1652+
*
1653+
* This helper predicate makes it easy to join on both of these columns at once, avoiding
1654+
* pathological join orders in case the argument index should get joined first.
1655+
*/
1656+
pragma[noinline]
1657+
final SideEffectInstruction getAParameterSideEffect(int index) {
1658+
this = result.getPrimaryInstruction() and
1659+
index = result.(IndexedInstruction).getIndex()
1660+
}
16481661
}
16491662

16501663
/**

cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,6 +1645,19 @@ class CallInstruction extends Instruction {
16451645
* Gets the number of arguments of the call, including the `this` pointer, if any.
16461646
*/
16471647
final int getNumberOfArguments() { result = count(this.getAnArgumentOperand()) }
1648+
1649+
/**
1650+
* Holds if the result is a side effect for the argument at the specified index, or `this` if
1651+
* `index` is `-1`.
1652+
*
1653+
* This helper predicate makes it easy to join on both of these columns at once, avoiding
1654+
* pathological join orders in case the argument index should get joined first.
1655+
*/
1656+
pragma[noinline]
1657+
final SideEffectInstruction getAParameterSideEffect(int index) {
1658+
this = result.getPrimaryInstruction() and
1659+
index = result.(IndexedInstruction).getIndex()
1660+
}
16481661
}
16491662

16501663
/**

csharp/ql/src/experimental/ir/implementation/raw/Instruction.qll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,6 +1645,19 @@ class CallInstruction extends Instruction {
16451645
* Gets the number of arguments of the call, including the `this` pointer, if any.
16461646
*/
16471647
final int getNumberOfArguments() { result = count(this.getAnArgumentOperand()) }
1648+
1649+
/**
1650+
* Holds if the result is a side effect for the argument at the specified index, or `this` if
1651+
* `index` is `-1`.
1652+
*
1653+
* This helper predicate makes it easy to join on both of these columns at once, avoiding
1654+
* pathological join orders in case the argument index should get joined first.
1655+
*/
1656+
pragma[noinline]
1657+
final SideEffectInstruction getAParameterSideEffect(int index) {
1658+
this = result.getPrimaryInstruction() and
1659+
index = result.(IndexedInstruction).getIndex()
1660+
}
16481661
}
16491662

16501663
/**

csharp/ql/src/experimental/ir/implementation/unaliased_ssa/Instruction.qll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,6 +1645,19 @@ class CallInstruction extends Instruction {
16451645
* Gets the number of arguments of the call, including the `this` pointer, if any.
16461646
*/
16471647
final int getNumberOfArguments() { result = count(this.getAnArgumentOperand()) }
1648+
1649+
/**
1650+
* Holds if the result is a side effect for the argument at the specified index, or `this` if
1651+
* `index` is `-1`.
1652+
*
1653+
* This helper predicate makes it easy to join on both of these columns at once, avoiding
1654+
* pathological join orders in case the argument index should get joined first.
1655+
*/
1656+
pragma[noinline]
1657+
final SideEffectInstruction getAParameterSideEffect(int index) {
1658+
this = result.getPrimaryInstruction() and
1659+
index = result.(IndexedInstruction).getIndex()
1660+
}
16481661
}
16491662

16501663
/**

0 commit comments

Comments
 (0)