Skip to content

Commit 165779e

Browse files
authored
Merge pull request #4343 from rdmarsh2/rdmarsh2/cpp/ir-construction-qldoc
C++: Add some IR QLDoc
2 parents 18bdc05 + 713bdae commit 165779e

File tree

10 files changed

+58
-5
lines changed

10 files changed

+58
-5
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ private PhiOperandBase phiOperand(
7979
}
8080

8181
/**
82-
* A source operand of an `Instruction`. The operand represents a value consumed by the instruction.
82+
* An operand of an `Instruction`. The operand represents a use of the result of one instruction
83+
* (the defining instruction) in another instruction (the use instruction)
8384
*/
8485
class Operand extends TOperand {
8586
/** Gets a textual representation of this element. */

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ abstract class MemoryLocation extends TMemoryLocation {
133133
predicate isAlwaysAllocatedOnStack() { none() }
134134
}
135135

136+
/**
137+
* Represents a set of `MemoryLocation`s that cannot overlap with
138+
* `MemoryLocation`s outside of the set. The `VirtualVariable` will be
139+
* represented by a `MemoryLocation` that totally overlaps all other
140+
* `MemoryLocations` in the set.
141+
*/
136142
abstract class VirtualVariable extends MemoryLocation { }
137143

138144
abstract class AllocationMemoryLocation extends MemoryLocation {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ private PhiOperandBase phiOperand(
7979
}
8080

8181
/**
82-
* A source operand of an `Instruction`. The operand represents a value consumed by the instruction.
82+
* An operand of an `Instruction`. The operand represents a use of the result of one instruction
83+
* (the defining instruction) in another instruction (the use instruction)
8384
*/
8485
class Operand extends TOperand {
8586
/** Gets a textual representation of this element. */

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ private PhiOperandBase phiOperand(
7979
}
8080

8181
/**
82-
* A source operand of an `Instruction`. The operand represents a value consumed by the instruction.
82+
* An operand of an `Instruction`. The operand represents a use of the result of one instruction
83+
* (the defining instruction) in another instruction (the use instruction)
8384
*/
8485
class Operand extends TOperand {
8586
/** Gets a textual representation of this element. */

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ class MemoryLocation extends TMemoryLocation {
5959
final string getUniqueId() { result = var.getUniqueId() }
6060
}
6161

62+
/**
63+
* Represents a set of `MemoryLocation`s that cannot overlap with
64+
* `MemoryLocation`s outside of the set. The `VirtualVariable` will be
65+
* represented by a `MemoryLocation` that totally overlaps all other
66+
* `MemoryLocations` in the set.
67+
*/
6268
class VirtualVariable extends MemoryLocation { }
6369

6470
/** A virtual variable that groups all escaped memory within a function. */

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,33 @@ private newtype TOverlap =
33
TMustTotallyOverlap() or
44
TMustExactlyOverlap()
55

6+
/**
7+
* Represents a possible overlap between two memory ranges.
8+
*/
69
abstract class Overlap extends TOverlap {
710
abstract string toString();
811
}
912

13+
/**
14+
* Represents a partial overlap between two memory ranges, which may or may not
15+
* actually occur in practice.
16+
*/
1017
class MayPartiallyOverlap extends Overlap, TMayPartiallyOverlap {
1118
final override string toString() { result = "MayPartiallyOverlap" }
1219
}
1320

21+
/**
22+
* Represents an overlap in which the first memory range is known to include all
23+
* bits of the second memory range, but may be larger or have a different type.
24+
*/
1425
class MustTotallyOverlap extends Overlap, TMustTotallyOverlap {
1526
final override string toString() { result = "MustTotallyOverlap" }
1627
}
1728

29+
/**
30+
* Represents an overlap between two memory ranges that have the same extent and
31+
* the same type.
32+
*/
1833
class MustExactlyOverlap extends Overlap, TMustExactlyOverlap {
1934
final override string toString() { result = "MustExactlyOverlap" }
2035
}

csharp/ql/src/experimental/ir/implementation/raw/Operand.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ private PhiOperandBase phiOperand(
7979
}
8080

8181
/**
82-
* A source operand of an `Instruction`. The operand represents a value consumed by the instruction.
82+
* An operand of an `Instruction`. The operand represents a use of the result of one instruction
83+
* (the defining instruction) in another instruction (the use instruction)
8384
*/
8485
class Operand extends TOperand {
8586
/** Gets a textual representation of this element. */

csharp/ql/src/experimental/ir/implementation/unaliased_ssa/Operand.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ private PhiOperandBase phiOperand(
7979
}
8080

8181
/**
82-
* A source operand of an `Instruction`. The operand represents a value consumed by the instruction.
82+
* An operand of an `Instruction`. The operand represents a use of the result of one instruction
83+
* (the defining instruction) in another instruction (the use instruction)
8384
*/
8485
class Operand extends TOperand {
8586
/** Gets a textual representation of this element. */

csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/SimpleSSA.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ class MemoryLocation extends TMemoryLocation {
5959
final string getUniqueId() { result = var.getUniqueId() }
6060
}
6161

62+
/**
63+
* Represents a set of `MemoryLocation`s that cannot overlap with
64+
* `MemoryLocation`s outside of the set. The `VirtualVariable` will be
65+
* represented by a `MemoryLocation` that totally overlaps all other
66+
* `MemoryLocations` in the set.
67+
*/
6268
class VirtualVariable extends MemoryLocation { }
6369

6470
/** A virtual variable that groups all escaped memory within a function. */

csharp/ql/src/experimental/ir/internal/Overlap.qll

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,33 @@ private newtype TOverlap =
33
TMustTotallyOverlap() or
44
TMustExactlyOverlap()
55

6+
/**
7+
* Represents a possible overlap between two memory ranges.
8+
*/
69
abstract class Overlap extends TOverlap {
710
abstract string toString();
811
}
912

13+
/**
14+
* Represents a partial overlap between two memory ranges, which may or may not
15+
* actually occur in practice.
16+
*/
1017
class MayPartiallyOverlap extends Overlap, TMayPartiallyOverlap {
1118
final override string toString() { result = "MayPartiallyOverlap" }
1219
}
1320

21+
/**
22+
* Represents an overlap in which the first memory range is known to include all
23+
* bits of the second memory range, but may be larger or have a different type.
24+
*/
1425
class MustTotallyOverlap extends Overlap, TMustTotallyOverlap {
1526
final override string toString() { result = "MustTotallyOverlap" }
1627
}
1728

29+
/**
30+
* Represents an overlap between two memory ranges that have the same extent and
31+
* the same type.
32+
*/
1833
class MustExactlyOverlap extends Overlap, TMustExactlyOverlap {
1934
final override string toString() { result = "MustExactlyOverlap" }
2035
}

0 commit comments

Comments
 (0)