Skip to content

Commit 06d7953

Browse files
authored
Merge pull request #771 from jbj/sync-files-after-range-analysis
Approved by rdmarsh2
2 parents 6cc4c2d + 0f2c700 commit 06d7953

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,9 @@ class BinaryInstruction extends Instruction {
751751
result = getAnOperand().(RightOperand).getDefinitionInstruction()
752752
}
753753

754+
/**
755+
* Holds if this instruction's operands are `op1` and `op2`, in either order.
756+
*/
754757
final predicate hasOperands(Operand op1, Operand op2) {
755758
op1 = getAnOperand().(LeftOperand) and op2 = getAnOperand().(RightOperand)
756759
or

cpp/ql/src/semmle/code/cpp/ir/implementation/raw/gvn/ValueNumbering.qll

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ class ValueNumber extends TValueNumber {
8383
instr order by instr.getBlock().getDisplayIndex(), instr.getDisplayIndexInBlock()
8484
)
8585
}
86+
87+
final Operand getAUse() {
88+
this = valueNumber(result.getDefinitionInstruction())
89+
}
8690
}
8791

8892
/**
@@ -212,14 +216,21 @@ private predicate uniqueValueNumber(Instruction instr, FunctionIR funcIR) {
212216
/**
213217
* Gets the value number assigned to `instr`, if any. Returns at most one result.
214218
*/
215-
ValueNumber valueNumber(Instruction instr) {
219+
cached ValueNumber valueNumber(Instruction instr) {
216220
result = nonUniqueValueNumber(instr) or
217221
exists(FunctionIR funcIR |
218222
uniqueValueNumber(instr, funcIR) and
219223
result = TUniqueValueNumber(funcIR, instr)
220224
)
221225
}
222226

227+
/**
228+
* Gets the value number assigned to `instr`, if any. Returns at most one result.
229+
*/
230+
ValueNumber valueNumberOfOperand(Operand op) {
231+
result = valueNumber(op.getDefinitionInstruction())
232+
}
233+
223234
/**
224235
* Gets the value number assigned to `instr`, if any, unless that instruction is assigned a unique
225236
* value number.

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,9 @@ class BinaryInstruction extends Instruction {
751751
result = getAnOperand().(RightOperand).getDefinitionInstruction()
752752
}
753753

754+
/**
755+
* Holds if this instruction's operands are `op1` and `op2`, in either order.
756+
*/
754757
final predicate hasOperands(Operand op1, Operand op2) {
755758
op1 = getAnOperand().(LeftOperand) and op2 = getAnOperand().(RightOperand)
756759
or

cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/gvn/ValueNumbering.qll

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ class ValueNumber extends TValueNumber {
8383
instr order by instr.getBlock().getDisplayIndex(), instr.getDisplayIndexInBlock()
8484
)
8585
}
86+
87+
final Operand getAUse() {
88+
this = valueNumber(result.getDefinitionInstruction())
89+
}
8690
}
8791

8892
/**
@@ -212,14 +216,21 @@ private predicate uniqueValueNumber(Instruction instr, FunctionIR funcIR) {
212216
/**
213217
* Gets the value number assigned to `instr`, if any. Returns at most one result.
214218
*/
215-
ValueNumber valueNumber(Instruction instr) {
219+
cached ValueNumber valueNumber(Instruction instr) {
216220
result = nonUniqueValueNumber(instr) or
217221
exists(FunctionIR funcIR |
218222
uniqueValueNumber(instr, funcIR) and
219223
result = TUniqueValueNumber(funcIR, instr)
220224
)
221225
}
222226

227+
/**
228+
* Gets the value number assigned to `instr`, if any. Returns at most one result.
229+
*/
230+
ValueNumber valueNumberOfOperand(Operand op) {
231+
result = valueNumber(op.getDefinitionInstruction())
232+
}
233+
223234
/**
224235
* Gets the value number assigned to `instr`, if any, unless that instruction is assigned a unique
225236
* value number.

0 commit comments

Comments
 (0)