Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c70bd28

Browse files
author
Robert Marsh
committed
C++: assume arguments to virtual functions escape
1 parent 2c94a88 commit c70bd28

4 files changed

Lines changed: 6 additions & 5 deletions

File tree

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ predicate operandIsPropagated(Operand operand, IntValue bitOffset) {
152152
// result does not itself escape.
153153
operandIsPropagated(operand, _) and not resultEscapes(operand.getUseInstruction())
154154
or
155-
// The address is passed as an argument to a function from which it does not escape
155+
// The operand is used in a function call from which the operand does not escape
156156
exists(CallInstruction ci, FunctionIR f, Instruction init |
157157
ci = operand.getUseInstruction() and
158158
f.getFunction() = ci.getStaticCallTarget() and
@@ -163,6 +163,7 @@ predicate operandIsPropagated(Operand operand, IntValue bitOffset) {
163163
init.getEnclosingFunctionIR() = f and
164164
operand instanceof ThisArgumentOperand
165165
) and
166+
not exists(f.getFunction().getAnOverload()) and
166167
not resultEscapesNonReturn(init) and
167168
(
168169
not resultReturned(init)
@@ -195,6 +196,7 @@ predicate operandEscapesNonReturn(Operand operand) {
195196
init.getEnclosingFunctionIR() = f and
196197
operand instanceof ThisArgumentOperand
197198
) and
199+
not exists(f.getFunction().getAnOverload()) and
198200
not resultEscapesNonReturn(init) and
199201
not resultEscapesNonReturn(ci)
200202
) or

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ predicate operandIsPropagated(Operand operand, IntValue bitOffset) {
152152
// result does not itself escape.
153153
operandIsPropagated(operand, _) and not resultEscapes(operand.getUseInstruction())
154154
or
155-
// The address is passed as an argument to a function from which it does not escape
155+
// The operand is used in a function call from which the operand does not escape
156156
exists(CallInstruction ci, FunctionIR f, Instruction init |
157157
ci = operand.getUseInstruction() and
158158
f.getFunction() = ci.getStaticCallTarget() and
@@ -163,6 +163,7 @@ predicate operandIsPropagated(Operand operand, IntValue bitOffset) {
163163
init.getEnclosingFunctionIR() = f and
164164
operand instanceof ThisArgumentOperand
165165
) and
166+
not exists(f.getFunction().getAnOverload()) and
166167
not resultEscapesNonReturn(init) and
167168
(
168169
not resultReturned(init)
@@ -195,6 +196,7 @@ predicate operandEscapesNonReturn(Operand operand) {
195196
init.getEnclosingFunctionIR() = f and
196197
operand instanceof ThisArgumentOperand
197198
) and
199+
not exists(f.getFunction().getAnOverload()) and
198200
not resultEscapesNonReturn(init) and
199201
not resultEscapesNonReturn(ci)
200202
) or
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
| escape.cpp:237:18:237:20 | on1 |
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
| escape.cpp:231:21:231:23 | or1 |
2-
| escape.cpp:237:18:237:20 | on1 |

0 commit comments

Comments
 (0)