Skip to content

Commit

Permalink
C++: Stub 'VariableGroup' and 'GroupedMemoryLocation' in unaliased SS…
Browse files Browse the repository at this point in the history
…A so that the pyrameterized files compile.
  • Loading branch information
MathiasVP committed Jul 4, 2024
1 parent db525f5 commit 92e814b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ newtype TInstruction =
TUnaliasedSsaUnreachedInstruction(IRFunctionBase irFunc) {
UnaliasedSsa::Ssa::hasUnreachedInstruction(irFunc)
} or
TUnaliasedSsaInitializeGroupInstruction(UnaliasedSsa::Ssa::VariableGroup vg) or
TAliasedSsaPhiInstruction(
TRawInstruction blockStartInstr, AliasedSsa::Ssa::MemoryLocation memoryLocation
) {
Expand Down Expand Up @@ -72,6 +73,16 @@ module UnaliasedSsaInstructions {
TUnreachedInstruction unreachedInstruction(IRFunctionBase irFunc) {
result = TUnaliasedSsaUnreachedInstruction(irFunc)
}

class VariableGroup = UnaliasedSsa::Ssa::VariableGroup;

class TInitializeGroupInstruction = TUnaliasedSsaInitializeGroupInstruction;

class TRawOrInitializeGroupInstruction = TRawInstruction or TInitializeGroupInstruction;

// This really should just be `TUnaliasedSsaInitializeGroupInstruction`, but that makes the
// compiler realize that certain expressions in `SSAConstruction` are unsatisfiable.
TRawOrInitializeGroupInstruction initializeGroup(VariableGroup vg) { none() }
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import AliasAnalysis
private import SimpleSSAImports
import SimpleSSAPublicImports
private import AliasConfiguration
private import codeql.util.Unit

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

predicate canReuseSsaForOldResult(Instruction instr) { none() }

abstract class VariableGroup extends Unit {
abstract Allocation getAnAllocation();

string toString() { result = "{" + strictconcat(this.getAnAllocation().toString(), ", ") + "}" }

abstract Language::Location getLocation();

abstract IRFunction getIRFunction();

abstract Language::LanguageType getType();

abstract int getInitializationOrder();
}

class GroupedMemoryLocation extends MemoryLocation {
VariableGroup vg;

GroupedMemoryLocation() { none() }

/** Gets an allocation of this memory location. */
Allocation getAnAllocation() { result = vg.getAnAllocation() }

/** Gets the set of allocations associated with this memory location. */
VariableGroup getGroup() { result = vg }

predicate isMayAccess() { none() }

/** Holds if this memory location represents all the enclosing allocations. */
predicate isAll() { none() }

/** Holds if this memory location represents one or more of the enclosing allocations. */
predicate isSome() { none() }
}

/**
* Represents a set of `MemoryLocation`s that cannot overlap with
* `MemoryLocation`s outside of the set. The `VirtualVariable` will be
Expand Down

0 comments on commit 92e814b

Please sign in to comment.