Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f4ce7b9

Browse files
committed
C++: respond to further PR review comments
1 parent 7ef0d5e commit f4ce7b9

9 files changed

Lines changed: 137 additions & 6 deletions

File tree

cpp/ql/src/semmle/code/cpp/ir/implementation/MemoryAccessKind.qll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class PhiMemoryAccess extends MemoryAccessKind, TPhiMemoryAccess {
8181
}
8282

8383
/**
84-
* The operand is a ChiOld operand, which accesses the same memory as its
84+
* The operand is a ChiTotal operand, which accesses the same memory as its
8585
* definition.
8686
*/
8787
class ChiTotalMemoryAccess extends MemoryAccessKind, TChiOldMemoryAccess {
@@ -91,14 +91,15 @@ class ChiTotalMemoryAccess extends MemoryAccessKind, TChiOldMemoryAccess {
9191
}
9292

9393
/**
94-
* The operand is a ChiUpdate operand, which accesses the same memory as its
94+
* The operand is a ChiPartial operand, which accesses the same memory as its
9595
* definition.
9696
*/
9797
class ChiPartialMemoryAccess extends MemoryAccessKind, TChiUpdateMemoryAccess {
9898
override string toString() {
9999
result = "chi(partial)"
100100
}
101101
}
102+
102103
/**
103104
* The operand accesses memory not modeled in SSA. Used only on the result of
104105
* `UnmodeledDefinition` and on the operands of `UnmodeledUse`.

cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,9 @@ class UnmodeledDefinitionInstruction extends Instruction {
13221322
}
13231323
}
13241324

1325+
/**
1326+
* An instruction that initializes all escaped memory.
1327+
*/
13251328
class AliasedDefinitionInstruction extends Instruction {
13261329
AliasedDefinitionInstruction() {
13271330
opcode instanceof Opcode::AliasedDefinition
@@ -1352,6 +1355,10 @@ class PhiInstruction extends Instruction {
13521355
}
13531356
}
13541357

1358+
/**
1359+
* An instruction representing the write to a piece of memory resulting from a write to a subset
1360+
* of that memory.
1361+
*/
13551362
class ChiInstruction extends Instruction {
13561363
ChiInstruction() {
13571364
opcode instanceof Opcode::Chi

cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Operand.qll

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,6 @@ class PhiOperand extends Operand, TPhiOperand {
382382
}
383383
}
384384

385-
386385
/**
387386
* An operand that reads a value from memory.
388387
*/
@@ -391,3 +390,38 @@ class MemoryOperand extends Operand {
391390
exists(getMemoryAccess())
392391
}
393392
}
393+
394+
/**
395+
* The total operand of a Chi node, representing the previous value of the memory.
396+
*/
397+
class ChiTotalOperand extends Operand {
398+
ChiTotalOperand() {
399+
this = TNonPhiOperand(_, chiTotalOperand(), _)
400+
}
401+
402+
override string toString() {
403+
result = "ChiTotal"
404+
}
405+
406+
override final MemoryAccessKind getMemoryAccess() {
407+
result instanceof ChiTotalMemoryAccess
408+
}
409+
}
410+
411+
412+
/**
413+
* The partial operand of a Chi node, representing the value being written to part of the memory.
414+
*/
415+
class ChiPartialOperand extends Operand {
416+
ChiPartialOperand() {
417+
this = TNonPhiOperand(_, chiPartialOperand(), _)
418+
}
419+
420+
override string toString() {
421+
result = "ChiPartial"
422+
}
423+
424+
override final MemoryAccessKind getMemoryAccess() {
425+
result instanceof ChiPartialMemoryAccess
426+
}
427+
}

cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Instruction.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,9 @@ class UnmodeledDefinitionInstruction extends Instruction {
13221322
}
13231323
}
13241324

1325+
/**
1326+
* An instruction that initializes all escaped memory.
1327+
*/
13251328
class AliasedDefinitionInstruction extends Instruction {
13261329
AliasedDefinitionInstruction() {
13271330
opcode instanceof Opcode::AliasedDefinition
@@ -1352,6 +1355,10 @@ class PhiInstruction extends Instruction {
13521355
}
13531356
}
13541357

1358+
/**
1359+
* An instruction representing the write to a piece of memory resulting from a write to a subset
1360+
* of that memory.
1361+
*/
13551362
class ChiInstruction extends Instruction {
13561363
ChiInstruction() {
13571364
opcode instanceof Opcode::Chi

cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Operand.qll

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,6 @@ class PhiOperand extends Operand, TPhiOperand {
382382
}
383383
}
384384

385-
386385
/**
387386
* An operand that reads a value from memory.
388387
*/
@@ -391,3 +390,38 @@ class MemoryOperand extends Operand {
391390
exists(getMemoryAccess())
392391
}
393392
}
393+
394+
/**
395+
* The total operand of a Chi node, representing the previous value of the memory.
396+
*/
397+
class ChiTotalOperand extends Operand {
398+
ChiTotalOperand() {
399+
this = TNonPhiOperand(_, chiTotalOperand(), _)
400+
}
401+
402+
override string toString() {
403+
result = "ChiTotal"
404+
}
405+
406+
override final MemoryAccessKind getMemoryAccess() {
407+
result instanceof ChiTotalMemoryAccess
408+
}
409+
}
410+
411+
412+
/**
413+
* The partial operand of a Chi node, representing the value being written to part of the memory.
414+
*/
415+
class ChiPartialOperand extends Operand {
416+
ChiPartialOperand() {
417+
this = TNonPhiOperand(_, chiPartialOperand(), _)
418+
}
419+
420+
override string toString() {
421+
result = "ChiPartial"
422+
}
423+
424+
override final MemoryAccessKind getMemoryAccess() {
425+
result instanceof ChiPartialMemoryAccess
426+
}
427+
}

cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,9 @@ class UnmodeledDefinitionInstruction extends Instruction {
13221322
}
13231323
}
13241324

1325+
/**
1326+
* An instruction that initializes all escaped memory.
1327+
*/
13251328
class AliasedDefinitionInstruction extends Instruction {
13261329
AliasedDefinitionInstruction() {
13271330
opcode instanceof Opcode::AliasedDefinition
@@ -1352,6 +1355,10 @@ class PhiInstruction extends Instruction {
13521355
}
13531356
}
13541357

1358+
/**
1359+
* An instruction representing the write to a piece of memory resulting from a write to a subset
1360+
* of that memory.
1361+
*/
13551362
class ChiInstruction extends Instruction {
13561363
ChiInstruction() {
13571364
opcode instanceof Opcode::Chi

cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Operand.qll

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,6 @@ class PhiOperand extends Operand, TPhiOperand {
382382
}
383383
}
384384

385-
386385
/**
387386
* An operand that reads a value from memory.
388387
*/
@@ -391,3 +390,38 @@ class MemoryOperand extends Operand {
391390
exists(getMemoryAccess())
392391
}
393392
}
393+
394+
/**
395+
* The total operand of a Chi node, representing the previous value of the memory.
396+
*/
397+
class ChiTotalOperand extends Operand {
398+
ChiTotalOperand() {
399+
this = TNonPhiOperand(_, chiTotalOperand(), _)
400+
}
401+
402+
override string toString() {
403+
result = "ChiTotal"
404+
}
405+
406+
override final MemoryAccessKind getMemoryAccess() {
407+
result instanceof ChiTotalMemoryAccess
408+
}
409+
}
410+
411+
412+
/**
413+
* The partial operand of a Chi node, representing the value being written to part of the memory.
414+
*/
415+
class ChiPartialOperand extends Operand {
416+
ChiPartialOperand() {
417+
this = TNonPhiOperand(_, chiPartialOperand(), _)
418+
}
419+
420+
override string toString() {
421+
result = "ChiPartial"
422+
}
423+
424+
override final MemoryAccessKind getMemoryAccess() {
425+
result instanceof ChiPartialMemoryAccess
426+
}
427+
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ private newtype TVirtualVariable =
99
not variableAddressEscapes(var)
1010
}
1111

12-
1312
private VirtualVariable getVirtualVariable(IRVariable var) {
1413
result.getIRVariable() = var
1514
}

cpp/ql/src/semmle/code/cpp/ir/internal/OperandTag.qll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,10 @@ class ChiTotalOperandTag extends OperandTag, TChiTotalOperand {
325325
}
326326
}
327327

328+
ChiTotalOperandTag chiTotalOperand() {
329+
result = TChiTotalOperand()
330+
}
331+
328332
class ChiPartialOperandTag extends OperandTag, TChiPartialOperand {
329333
override final string toString() {
330334
result = "ChiPartial"
@@ -334,3 +338,7 @@ class ChiPartialOperandTag extends OperandTag, TChiPartialOperand {
334338
result = 15
335339
}
336340
}
341+
342+
ChiPartialOperandTag chiPartialOperand() {
343+
result = TChiPartialOperand()
344+
}

0 commit comments

Comments
 (0)