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

Skip to content

Commit a72cd23

Browse files
author
Robert Marsh
committed
C++: fix escape test failures
1 parent 09321ee commit a72cd23

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ predicate operandEscapesDomain(Operand operand) {
7171
not operandIsConsumedWithoutEscaping(operand) and
7272
not operandIsPropagated(operand, _) and
7373
not isArgumentForParameter(_, operand, _) and
74-
not isOnlyEscapesViaReturnArgument(operand)
74+
not isOnlyEscapesViaReturnArgument(operand) and
75+
not operand.getUseInstruction() instanceof ReturnValueInstruction
7576
}
7677

7778
/**

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ predicate operandEscapesDomain(Operand operand) {
7171
not operandIsConsumedWithoutEscaping(operand) and
7272
not operandIsPropagated(operand, _) and
7373
not isArgumentForParameter(_, operand, _) and
74-
not isOnlyEscapesViaReturnArgument(operand)
74+
not isOnlyEscapesViaReturnArgument(operand) and
75+
not operand.getUseInstruction() instanceof ReturnValueInstruction
7576
}
7677

7778
/**
@@ -208,21 +209,21 @@ predicate isArgumentForParameter(CallInstruction ci, Operand operand, Instructio
208209
)
209210
}
210211

211-
predicate isAlwaysReturnedArgument(Operand operand) {
212+
private predicate isAlwaysReturnedArgument(Operand operand) {
212213
exists(AliasFunction f |
213214
f = operand.getUseInstruction().(CallInstruction).getStaticCallTarget() and
214215
f.parameterIsAlwaysReturned(operand.(PositionalArgumentOperand).getIndex())
215216
)
216217
}
217218

218-
predicate isOnlyEscapesViaReturnArgument(Operand operand) {
219+
private predicate isOnlyEscapesViaReturnArgument(Operand operand) {
219220
exists(AliasFunction f |
220221
f = operand.getUseInstruction().(CallInstruction).getStaticCallTarget() and
221222
f.parameterEscapesOnlyViaReturn(operand.(PositionalArgumentOperand).getIndex())
222223
)
223224
}
224225

225-
predicate isNeverEscapesArgument(Operand operand) {
226+
private predicate isNeverEscapesArgument(Operand operand) {
226227
exists(AliasFunction f |
227228
f = operand.getUseInstruction().(CallInstruction).getStaticCallTarget() and
228229
f.parameterNeverEscapes(operand.(PositionalArgumentOperand).getIndex())

0 commit comments

Comments
 (0)