Skip to content

Commit 92e814b

Browse files
committed
C++: Stub 'VariableGroup' and 'GroupedMemoryLocation' in unaliased SSA so that the pyrameterized files compile.
1 parent db525f5 commit 92e814b

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

cpp/ql/lib/semmle/code/cpp/ir/implementation/internal/TInstruction.qll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ newtype TInstruction =
3131
TUnaliasedSsaUnreachedInstruction(IRFunctionBase irFunc) {
3232
UnaliasedSsa::Ssa::hasUnreachedInstruction(irFunc)
3333
} or
34+
TUnaliasedSsaInitializeGroupInstruction(UnaliasedSsa::Ssa::VariableGroup vg) or
3435
TAliasedSsaPhiInstruction(
3536
TRawInstruction blockStartInstr, AliasedSsa::Ssa::MemoryLocation memoryLocation
3637
) {
@@ -72,6 +73,16 @@ module UnaliasedSsaInstructions {
7273
TUnreachedInstruction unreachedInstruction(IRFunctionBase irFunc) {
7374
result = TUnaliasedSsaUnreachedInstruction(irFunc)
7475
}
76+
77+
class VariableGroup = UnaliasedSsa::Ssa::VariableGroup;
78+
79+
class TInitializeGroupInstruction = TUnaliasedSsaInitializeGroupInstruction;
80+
81+
class TRawOrInitializeGroupInstruction = TRawInstruction or TInitializeGroupInstruction;
82+
83+
// This really should just be `TUnaliasedSsaInitializeGroupInstruction`, but that makes the
84+
// compiler realize that certain expressions in `SSAConstruction` are unsatisfiable.
85+
TRawOrInitializeGroupInstruction initializeGroup(VariableGroup vg) { none() }
7586
}
7687

7788
/**

cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SimpleSSA.qll

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import AliasAnalysis
22
private import SimpleSSAImports
33
import SimpleSSAPublicImports
44
private import AliasConfiguration
5+
private import codeql.util.Unit
56

67
private predicate isTotalAccess(Allocation var, AddressOperand addrOperand, IRType type) {
78
exists(Instruction constantBase, int bitOffset |
@@ -77,6 +78,40 @@ class MemoryLocation extends TMemoryLocation {
7778

7879
predicate canReuseSsaForOldResult(Instruction instr) { none() }
7980

81+
abstract class VariableGroup extends Unit {
82+
abstract Allocation getAnAllocation();
83+
84+
string toString() { result = "{" + strictconcat(this.getAnAllocation().toString(), ", ") + "}" }
85+
86+
abstract Language::Location getLocation();
87+
88+
abstract IRFunction getIRFunction();
89+
90+
abstract Language::LanguageType getType();
91+
92+
abstract int getInitializationOrder();
93+
}
94+
95+
class GroupedMemoryLocation extends MemoryLocation {
96+
VariableGroup vg;
97+
98+
GroupedMemoryLocation() { none() }
99+
100+
/** Gets an allocation of this memory location. */
101+
Allocation getAnAllocation() { result = vg.getAnAllocation() }
102+
103+
/** Gets the set of allocations associated with this memory location. */
104+
VariableGroup getGroup() { result = vg }
105+
106+
predicate isMayAccess() { none() }
107+
108+
/** Holds if this memory location represents all the enclosing allocations. */
109+
predicate isAll() { none() }
110+
111+
/** Holds if this memory location represents one or more of the enclosing allocations. */
112+
predicate isSome() { none() }
113+
}
114+
80115
/**
81116
* Represents a set of `MemoryLocation`s that cannot overlap with
82117
* `MemoryLocation`s outside of the set. The `VirtualVariable` will be

0 commit comments

Comments
 (0)