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

Skip to content

Commit 6f76c13

Browse files
author
Robert Marsh
committed
C++: fix unused variable warning
1 parent 726f38c commit 6f76c13

2 files changed

Lines changed: 6 additions & 22 deletions

File tree

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ predicate operandIsPropagated(Operand operand, IntValue bitOffset) {
153153
operandIsPropagated(operand, _) and not resultEscapes(operand.getUseInstruction())
154154
or
155155
// The operand is used in a function call from which the operand does not escape
156-
exists(CallInstruction ci, FunctionIR f, Instruction init |
156+
exists(CallInstruction ci, Instruction init |
157157
ci = operand.getUseInstruction() and
158158
isArgumentForParameter(ci, operand, init) and
159159
not resultEscapesNonReturn(init) and
@@ -183,7 +183,7 @@ predicate operandEscapesNonReturn(Operand operand) {
183183
not resultEscapesNonReturn(init) and
184184
not resultEscapesNonReturn(ci)
185185
) or
186-
operand instanceof ReturnValueOperand
186+
operand.getUseInstruction() instanceof ReturnValueInstruction
187187
)
188188
}
189189

@@ -193,14 +193,6 @@ predicate operandReturned(Operand operand) {
193193
operandIsPropagated(operand, _) and resultReturned(operand.getUseInstruction())
194194
or
195195
// The operand is used in a function call which returns it, and the return value is then returned
196-
exists(CallInstruction ci, FunctionIR f, InitializeParameterInstruction ipi |
197-
ci = operand.getUseInstruction() and
198-
f.getFunction() = ci.getStaticCallTarget() and
199-
ipi.getParameter() = f.getFunction().getParameter(operand.(PositionalArgumentOperand).getIndex()) and
200-
resultReturned(ipi) and
201-
resultReturned(ci)
202-
)
203-
or
204196
exists(CallInstruction ci, Instruction init |
205197
ci = operand.getUseInstruction() and
206198
isArgumentForParameter(ci, operand, init) and
@@ -209,7 +201,7 @@ predicate operandReturned(Operand operand) {
209201
)
210202
or
211203
// The address is returned
212-
operand instanceof ReturnValueOperand
204+
operand.getUseInstruction() instanceof ReturnValueInstruction
213205
}
214206

215207
predicate isArgumentForParameter(CallInstruction ci, Operand operand, Instruction init) {

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ predicate operandIsPropagated(Operand operand, IntValue bitOffset) {
153153
operandIsPropagated(operand, _) and not resultEscapes(operand.getUseInstruction())
154154
or
155155
// The operand is used in a function call from which the operand does not escape
156-
exists(CallInstruction ci, FunctionIR f, Instruction init |
156+
exists(CallInstruction ci, Instruction init |
157157
ci = operand.getUseInstruction() and
158158
isArgumentForParameter(ci, operand, init) and
159159
not resultEscapesNonReturn(init) and
@@ -183,7 +183,7 @@ predicate operandEscapesNonReturn(Operand operand) {
183183
not resultEscapesNonReturn(init) and
184184
not resultEscapesNonReturn(ci)
185185
) or
186-
operand instanceof ReturnValueOperand
186+
operand.getUseInstruction() instanceof ReturnValueInstruction
187187
)
188188
}
189189

@@ -193,14 +193,6 @@ predicate operandReturned(Operand operand) {
193193
operandIsPropagated(operand, _) and resultReturned(operand.getUseInstruction())
194194
or
195195
// The operand is used in a function call which returns it, and the return value is then returned
196-
exists(CallInstruction ci, FunctionIR f, InitializeParameterInstruction ipi |
197-
ci = operand.getUseInstruction() and
198-
f.getFunction() = ci.getStaticCallTarget() and
199-
ipi.getParameter() = f.getFunction().getParameter(operand.(PositionalArgumentOperand).getIndex()) and
200-
resultReturned(ipi) and
201-
resultReturned(ci)
202-
)
203-
or
204196
exists(CallInstruction ci, Instruction init |
205197
ci = operand.getUseInstruction() and
206198
isArgumentForParameter(ci, operand, init) and
@@ -209,7 +201,7 @@ predicate operandReturned(Operand operand) {
209201
)
210202
or
211203
// The address is returned
212-
operand instanceof ReturnValueOperand
204+
operand.getUseInstruction() instanceof ReturnValueInstruction
213205
}
214206

215207
predicate isArgumentForParameter(CallInstruction ci, Operand operand, Instruction init) {

0 commit comments

Comments
 (0)