Skip to content

Commit 52cfbff

Browse files
committed
C++ IR: Fix calls to non-existent predicates
The last commit introduced calls to two predicates that did not exist. I created `Instruction.getResultAddress` so it now exists and changed the other call back to use the predicate that does exist.
1 parent 6d87c05 commit 52cfbff

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ class Instruction extends Construction::TInstruction {
510510
}
511511

512512
/**
513-
* Returns the operand that holds the memory address to which the instruction stores its
513+
* Gets the operand that holds the memory address to which this instruction stores its
514514
* result, if any. For example, in `m3 = Store r1, r2`, the result of `getResultAddressOperand()`
515515
* is `r1`.
516516
*/
@@ -519,6 +519,15 @@ class Instruction extends Construction::TInstruction {
519519
result.getUse() = this
520520
}
521521

522+
/**
523+
* Gets the instruction that holds the exact memory address to which this instruction stores its
524+
* result, if any. For example, in `m3 = Store r1, r2`, the result of `getResultAddressOperand()`
525+
* is the instruction that defines `r1`.
526+
*/
527+
final Instruction getResultAddress() {
528+
result = getResultAddressOperand().getDef()
529+
}
530+
522531
/**
523532
* Holds if the result of this instruction is precisely modeled in SSA. Always
524533
* holds for a register result. For a memory result, a modeled result is

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ private predicate hasResultMemoryAccess(Instruction instr, IRVariable var, Type
2121

2222
private predicate hasOperandMemoryAccess(MemoryOperand operand, IRVariable var, Type type, IntValue startBitOffset,
2323
IntValue endBitOffset) {
24-
resultPointsTo(operand.getAddress().getAnyDef(), var, startBitOffset) and
24+
resultPointsTo(operand.getAddressOperand().getAnyDef(), var, startBitOffset) and
2525
type = operand.getType() and
2626
if exists(operand.getSize()) then
2727
endBitOffset = Ints::add(startBitOffset, Ints::mul(operand.getSize(), 8))

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ class Instruction extends Construction::TInstruction {
510510
}
511511

512512
/**
513-
* Returns the operand that holds the memory address to which the instruction stores its
513+
* Gets the operand that holds the memory address to which this instruction stores its
514514
* result, if any. For example, in `m3 = Store r1, r2`, the result of `getResultAddressOperand()`
515515
* is `r1`.
516516
*/
@@ -519,6 +519,15 @@ class Instruction extends Construction::TInstruction {
519519
result.getUse() = this
520520
}
521521

522+
/**
523+
* Gets the instruction that holds the exact memory address to which this instruction stores its
524+
* result, if any. For example, in `m3 = Store r1, r2`, the result of `getResultAddressOperand()`
525+
* is the instruction that defines `r1`.
526+
*/
527+
final Instruction getResultAddress() {
528+
result = getResultAddressOperand().getDef()
529+
}
530+
522531
/**
523532
* Holds if the result of this instruction is precisely modeled in SSA. Always
524533
* holds for a register result. For a memory result, a modeled result is

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ class Instruction extends Construction::TInstruction {
510510
}
511511

512512
/**
513-
* Returns the operand that holds the memory address to which the instruction stores its
513+
* Gets the operand that holds the memory address to which this instruction stores its
514514
* result, if any. For example, in `m3 = Store r1, r2`, the result of `getResultAddressOperand()`
515515
* is `r1`.
516516
*/
@@ -519,6 +519,15 @@ class Instruction extends Construction::TInstruction {
519519
result.getUse() = this
520520
}
521521

522+
/**
523+
* Gets the instruction that holds the exact memory address to which this instruction stores its
524+
* result, if any. For example, in `m3 = Store r1, r2`, the result of `getResultAddressOperand()`
525+
* is the instruction that defines `r1`.
526+
*/
527+
final Instruction getResultAddress() {
528+
result = getResultAddressOperand().getDef()
529+
}
530+
522531
/**
523532
* Holds if the result of this instruction is precisely modeled in SSA. Always
524533
* holds for a register result. For a memory result, a modeled result is

0 commit comments

Comments
 (0)