Skip to content

Commit

Permalink
C++: Remove the 'BaseSourceVariableInstruction' column as it's functi…
Browse files Browse the repository at this point in the history
…onally determined by the address column.
  • Loading branch information
MathiasVP committed Apr 22, 2024
1 parent bea7b94 commit 41de946
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaInternals.qll
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,9 @@ predicate hasRawIndirectInstruction(Instruction instr, int indirectionIndex) {
cached
private newtype TDefOrUseImpl =
TDefAddressImpl(BaseIRVariable v) or
TDefImpl(BaseSourceVariableInstruction base, Operand address, int indirectionIndex) {
isDef(_, _, address, base, _, indirectionIndex)
} or
TUseImpl(BaseSourceVariableInstruction base, Operand operand, int indirectionIndex) {
isUse(_, operand, base, _, indirectionIndex) and
TDefImpl(Operand address, int indirectionIndex) { isDef(_, _, address, _, _, indirectionIndex) } or
TUseImpl(Operand operand, int indirectionIndex) {
isUse(_, operand, _, _, indirectionIndex) and
not isDef(true, _, operand, _, _, _)
} or
TGlobalUse(GlobalLikeVariable v, IRFunction f, int indirectionIndex) {
Expand Down Expand Up @@ -323,17 +321,15 @@ abstract private class OperandBasedDef extends DefImpl {
}

private class DirectDef extends OperandBasedDef, TDefImpl {
BaseSourceVariableInstruction base;

DirectDef() { this = TDefImpl(base, address, ind) }
DirectDef() { this = TDefImpl(address, ind) }

override BaseSourceVariableInstruction getBase() { result = base }
override BaseSourceVariableInstruction getBase() { isDef(_, _, address, result, _, ind) }

override int getIndirection() { isDef(_, _, address, base, result, ind) }
override int getIndirection() { isDef(_, _, address, _, result, ind) }

override Node0Impl getValue() { isDef(_, result, address, base, _, _) }
override Node0Impl getValue() { isDef(_, result, address, _, _, _) }

override predicate isCertain() { isDef(true, _, address, base, _, ind) }
override predicate isCertain() { isDef(true, _, address, _, _, ind) }
}

private class IteratorDef extends OperandBasedDef, TIteratorDef {
Expand Down Expand Up @@ -376,19 +372,19 @@ abstract class UseImpl extends DefOrUseImpl {

abstract private class OperandBasedUse extends UseImpl {
Operand operand;
BaseSourceVariableInstruction base;

bindingset[ind]
OperandBasedUse() { any() }

final override predicate hasIndexInBlock(IRBlock block, int index) {
// See the comment in `ssa0`'s `OperandBasedUse` for an explanation of this
// predicate's implementation.
if base.getAst() = any(Cpp::PostfixCrementOperation c).getOperand()
if this.getBase().getAst() = any(Cpp::PostfixCrementOperation c).getOperand()
then
exists(Operand op, int indirectionIndex, int indirection |
exists(Operand op, int indirectionIndex, int indirection, BaseSourceVariableInstruction base |
indirectionIndex = this.getIndirectionIndex() and
indirection = this.getIndirection() and
base = this.getBase() and
op =
min(Operand cand, int i |
isUse(_, cand, base, indirection, indirectionIndex) and
Expand All @@ -401,31 +397,35 @@ abstract private class OperandBasedUse extends UseImpl {
else operand.getUse() = block.getInstruction(index)
}

final override BaseSourceVariableInstruction getBase() { result = base }

final Operand getOperand() { result = operand }

final override Cpp::Location getLocation() { result = operand.getLocation() }
}

private class DirectUse extends OperandBasedUse, TUseImpl {
DirectUse() { this = TUseImpl(base, operand, ind) }
DirectUse() { this = TUseImpl(operand, ind) }

override int getIndirection() { isUse(_, operand, base, result, ind) }
override int getIndirection() { isUse(_, operand, _, result, ind) }

override predicate isCertain() { isUse(true, operand, base, _, ind) }
override predicate isCertain() { isUse(true, operand, _, _, ind) }

override Node getNode() { nodeHasOperand(result, operand, ind) }

final override BaseSourceVariableInstruction getBase() { isUse(_, operand, result, _, ind) }
}

private class IteratorUse extends OperandBasedUse, TIteratorUse {
IteratorUse() { this = TIteratorUse(operand, base, ind) }
BaseSourceVariableInstruction container;

IteratorUse() { this = TIteratorUse(operand, container, ind) }

override int getIndirection() { isIteratorUse(base, operand, result, ind) }
override int getIndirection() { isIteratorUse(container, operand, result, ind) }

override predicate isCertain() { none() }

override Node getNode() { nodeHasOperand(result, operand, ind) }

final override BaseSourceVariableInstruction getBase() { result = container }
}

pragma[nomagic]
Expand Down

0 comments on commit 41de946

Please sign in to comment.