Skip to content

Commit 7be2a67

Browse files
authored
Merge pull request #22503 from MathiasVP/cpp-fix-two-joins
C++: Fix two joins in IR construction
2 parents 4a21348 + c99bff9 commit 7be2a67

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,11 @@ abstract class MemoryLocation0 extends TMemoryLocation {
295295
*/
296296
abstract class VirtualVariable extends MemoryLocation0 { }
297297

298+
pragma[nomagic]
299+
private VirtualVariable getAllocationMemoryLocation(Allocation alloc) {
300+
result.getAnAllocation() = alloc
301+
}
302+
298303
abstract class AllocationMemoryLocation extends MemoryLocation0 {
299304
Allocation var;
300305
boolean isMayAccess;
@@ -313,7 +318,7 @@ abstract class AllocationMemoryLocation extends MemoryLocation0 {
313318
result = getGroupedMemoryLocation(var, false, false).getVirtualVariable()
314319
or
315320
not exists(getGroupedMemoryLocation(var, false, false)) and
316-
result.(AllocationMemoryLocation).getAnAllocation() = var
321+
result = getAllocationMemoryLocation(var)
317322
)
318323
}
319324

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedInitialization.qll

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,11 @@ class TranslatedExplicitFieldInitialization extends TranslatedNonDefaultFieldIni
618618
override int getPosition() { result = position }
619619
}
620620

621+
pragma[nomagic]
622+
private Instruction getCallInstruction(TranslatedDefaultFieldInitialization tdfi) {
623+
result = tdfi.getInstruction(CallTag())
624+
}
625+
621626
/**
622627
* The IR translation of the initialization of a field from an element of an initializer
623628
* list where default initialization is used.
@@ -642,7 +647,7 @@ class TranslatedDefaultFieldInitialization extends TranslatedFieldInitialization
642647

643648
override Instruction getInstructionSuccessorInternal(InstructionTag tag, EdgeKind kind) {
644649
tag = CallTargetTag() and
645-
result = this.getInstruction(CallTag())
650+
result = getCallInstruction(this)
646651
or
647652
tag = CallTag() and
648653
result = this.getSideEffects().getFirstInstruction(kind)

0 commit comments

Comments
 (0)