Skip to content

Commit 14aa642

Browse files
authored
Merge pull request github#4696 from MathiasVP/get-result-memory-___location-join-order-fix
C++: Fix bad join order in AliasedSSA::getResultMemoryLocation
2 parents 77afd5a + 490bba5 commit 14aa642

File tree

1 file changed

+6
-2
lines changed
  • cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,9 @@ private Overlap getVariableMemoryLocationOverlap(
566566
use.getEndBitOffset())
567567
}
568568

569+
bindingset[result, b]
570+
private boolean unbindBool(boolean b) { result != b.booleanNot() }
571+
569572
MemoryLocation getResultMemoryLocation(Instruction instr) {
570573
exists(MemoryAccessKind kind, boolean isMayAccess |
571574
kind = instr.getResultMemoryAccess() and
@@ -578,15 +581,16 @@ MemoryLocation getResultMemoryLocation(Instruction instr) {
578581
exists(Allocation var, IRType type, IntValue startBitOffset, IntValue endBitOffset |
579582
hasResultMemoryAccess(instr, var, type, _, startBitOffset, endBitOffset, isMayAccess) and
580583
result =
581-
TVariableMemoryLocation(var, type, _, startBitOffset, endBitOffset, isMayAccess)
584+
TVariableMemoryLocation(var, type, _, startBitOffset, endBitOffset,
585+
unbindBool(isMayAccess))
582586
)
583587
else result = TUnknownMemoryLocation(instr.getEnclosingIRFunction(), isMayAccess)
584588
)
585589
or
586590
kind instanceof EntireAllocationMemoryAccess and
587591
result =
588592
TEntireAllocationMemoryLocation(getAddressOperandAllocation(instr.getResultAddressOperand()),
589-
isMayAccess)
593+
unbindBool(isMayAccess))
590594
or
591595
kind instanceof EscapedMemoryAccess and
592596
result = TAllAliasedMemory(instr.getEnclosingIRFunction(), isMayAccess, false)

0 commit comments

Comments
 (0)