Skip to content

Commit 09c03d9

Browse files
committed
C++: The virtual variable of a variable that is contained in a grouped memory location is that grouped memory location (or all aliased memory if it escapes).
1 parent 399d47d commit 09c03d9

File tree

1 file changed

+10
-1
lines changed
  • cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal

1 file changed

+10
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,16 @@ abstract class AllocationMemoryLocation extends MemoryLocation {
246246
final override VirtualVariable getVirtualVariable() {
247247
if allocationEscapes(var)
248248
then result = TAllAliasedMemory(var.getEnclosingIRFunction(), false)
249-
else result.(AllocationMemoryLocation).getAllocation() = var
249+
else (
250+
// It may be that the grouped memory location contains an escaping
251+
// allocation. In that case, the virtual variable is still the memory
252+
// location that represents all aliased memory. Thus, we need to
253+
// call `getVirtualVariable` on the grouped memory location.
254+
result = getGroupedMemoryLocation(var, false, false).getVirtualVariable()
255+
or
256+
not exists(getGroupedMemoryLocation(var, false, false)) and
257+
result.(AllocationMemoryLocation).getAnAllocation() = var
258+
)
250259
}
251260

252261
final override IRFunction getIRFunction() { result = var.getEnclosingIRFunction() }

0 commit comments

Comments
 (0)