Skip to content

Commit 639864e

Browse files
Dave Bartolomeogeoffw0
authored andcommitted
Handle may vs. must for EntireAllocationMemoryLocation
1 parent b692b1b commit 639864e

File tree

2 files changed

+69
-2
lines changed

2 files changed

+69
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,8 +683,13 @@ private Overlap getExtentOverlap(MemoryLocation0 def, MemoryLocation0 use) {
683683
def.getVirtualVariable() = use.getVirtualVariable() and
684684
def instanceof EntireAllocationMemoryLocation and
685685
(
686-
// EntireAllocationMemoryLocation exactly overlaps itself.
687-
use = def and
686+
// EntireAllocationMemoryLocation exactly overlaps any EntireAllocationMemoryLocation for the
687+
// same allocation. Checking the allocation, rather than the memory location itself, ensures
688+
// that we get the right relationship between the "must" and "may" memory locations for that
689+
// allocation.
690+
// Note that if one of the locations is a "may" access, the overlap will be downgraded to
691+
// `MustTotallyOverlap` or `MayPartialOverlap` in `getOverlap()`.
692+
use.(EntireAllocationMemoryLocation).getAnAllocation() = def.getAnAllocation() and
688693
result instanceof MustExactlyOverlap
689694
or
690695
not use instanceof EntireAllocationMemoryLocation and

0 commit comments

Comments
 (0)