Skip to content

Commit 961a7dc

Browse files
committed
C++ IR: Remove Instruction.hasUse predicate
Now that it's been simplified to be the same as `getOperand`, it doesn't seem to have a purpose.
1 parent 8c06a68 commit 961a7dc

File tree

5 files changed

+8
-32
lines changed

5 files changed

+8
-32
lines changed

cpp/ql/src/semmle/code/cpp/ir/internal/Instruction.qll

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ class Instruction extends Construction::TInstruction {
269269
// Register results are always in SSA form.
270270
not hasMemoryResult() or
271271
// An unmodeled result will have a use on the `UnmodeledUse` instruction.
272-
not exists(UnmodeledUseOperand useTag |
273-
hasUse(_, useTag)
272+
not exists(Instruction useInstr, UnmodeledUseOperand useTag |
273+
this = useInstr.getOperand(useTag)
274274
)
275275
}
276276

@@ -303,14 +303,6 @@ class Instruction extends Construction::TInstruction {
303303
final Instruction getAPredecessor() {
304304
result = getPredecessor(_)
305305
}
306-
307-
/**
308-
* Holds if the result of this instruction is consumed by `useInstruction` as
309-
* an operand with tag `useTag`.
310-
*/
311-
final predicate hasUse(Instruction useInstruction, OperandTag useTag) {
312-
this = useInstruction.getOperand(useTag)
313-
}
314306
}
315307

316308
class VariableInstruction extends Instruction {

cpp/ql/src/semmle/code/cpp/ssa/internal/aliased_ssa/AliasAnalysis.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ predicate operandEscapes(Instruction instr, OperandTag tag) {
160160
predicate resultEscapes(Instruction instr) {
161161
// The result escapes if it has at least one use that escapes.
162162
exists(Instruction useInstr, OperandTag useOperandTag |
163-
instr.hasUse(useInstr, useOperandTag) and
163+
useInstr.getOperand(useOperandTag) = instr and
164164
operandEscapes(useInstr, useOperandTag)
165165
)
166166
}

cpp/ql/src/semmle/code/cpp/ssa/internal/aliased_ssa/Instruction.qll

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ class Instruction extends Construction::TInstruction {
269269
// Register results are always in SSA form.
270270
not hasMemoryResult() or
271271
// An unmodeled result will have a use on the `UnmodeledUse` instruction.
272-
not exists(UnmodeledUseOperand useTag |
273-
hasUse(_, useTag)
272+
not exists(Instruction useInstr, UnmodeledUseOperand useTag |
273+
this = useInstr.getOperand(useTag)
274274
)
275275
}
276276

@@ -303,14 +303,6 @@ class Instruction extends Construction::TInstruction {
303303
final Instruction getAPredecessor() {
304304
result = getPredecessor(_)
305305
}
306-
307-
/**
308-
* Holds if the result of this instruction is consumed by `useInstruction` as
309-
* an operand with tag `useTag`.
310-
*/
311-
final predicate hasUse(Instruction useInstruction, OperandTag useTag) {
312-
this = useInstruction.getOperand(useTag)
313-
}
314306
}
315307

316308
class VariableInstruction extends Instruction {

cpp/ql/src/semmle/code/cpp/ssa/internal/ssa/AliasAnalysis.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ predicate operandEscapes(Instruction instr, OperandTag tag) {
160160
predicate resultEscapes(Instruction instr) {
161161
// The result escapes if it has at least one use that escapes.
162162
exists(Instruction useInstr, OperandTag useOperandTag |
163-
instr.hasUse(useInstr, useOperandTag) and
163+
useInstr.getOperand(useOperandTag) = instr and
164164
operandEscapes(useInstr, useOperandTag)
165165
)
166166
}

cpp/ql/src/semmle/code/cpp/ssa/internal/ssa/Instruction.qll

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ class Instruction extends Construction::TInstruction {
269269
// Register results are always in SSA form.
270270
not hasMemoryResult() or
271271
// An unmodeled result will have a use on the `UnmodeledUse` instruction.
272-
not exists(UnmodeledUseOperand useTag |
273-
hasUse(_, useTag)
272+
not exists(Instruction useInstr, UnmodeledUseOperand useTag |
273+
this = useInstr.getOperand(useTag)
274274
)
275275
}
276276

@@ -303,14 +303,6 @@ class Instruction extends Construction::TInstruction {
303303
final Instruction getAPredecessor() {
304304
result = getPredecessor(_)
305305
}
306-
307-
/**
308-
* Holds if the result of this instruction is consumed by `useInstruction` as
309-
* an operand with tag `useTag`.
310-
*/
311-
final predicate hasUse(Instruction useInstruction, OperandTag useTag) {
312-
this = useInstruction.getOperand(useTag)
313-
}
314306
}
315307

316308
class VariableInstruction extends Instruction {

0 commit comments

Comments
 (0)