Skip to content

Commit 7e3f2db

Browse files
author
Dave Bartolomeo
committed
C++: Improve QLDoc for getElementSize()
1 parent b889d36 commit 7e3f2db

File tree

5 files changed

+40
-5
lines changed

5 files changed

+40
-5
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,14 @@ class PointerArithmeticInstruction extends BinaryInstruction {
10771077
final override string getImmediateString() { result = elementSize.toString() }
10781078

10791079
/**
1080-
* Gets the size of the element pointed to by the pointer, in bytes.
1080+
* Gets the size of the elements pointed to by the pointer operands, in bytes.
1081+
*
1082+
* When adding an integer offset to a pointer (`PointerAddInstruction`) or subtracting an integer
1083+
* offset from a pointer (`PointerSubInstruction`), the integer offset is multiplied by the
1084+
* element size to compute the actual number of bytes added to or subtracted from the pointer
1085+
* address. When computing the integer difference between two pointers (`PointerDiffInstruction`),
1086+
* the result is computed by computing the difference between the two pointer byte addresses, then
1087+
* dividing that byte count by the element size.
10811088
*/
10821089
final int getElementSize() { result = elementSize }
10831090
}

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,14 @@ class PointerArithmeticInstruction extends BinaryInstruction {
10771077
final override string getImmediateString() { result = elementSize.toString() }
10781078

10791079
/**
1080-
* Gets the size of the element pointed to by the pointer, in bytes.
1080+
* Gets the size of the elements pointed to by the pointer operands, in bytes.
1081+
*
1082+
* When adding an integer offset to a pointer (`PointerAddInstruction`) or subtracting an integer
1083+
* offset from a pointer (`PointerSubInstruction`), the integer offset is multiplied by the
1084+
* element size to compute the actual number of bytes added to or subtracted from the pointer
1085+
* address. When computing the integer difference between two pointers (`PointerDiffInstruction`),
1086+
* the result is computed by computing the difference between the two pointer byte addresses, then
1087+
* dividing that byte count by the element size.
10811088
*/
10821089
final int getElementSize() { result = elementSize }
10831090
}

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,14 @@ class PointerArithmeticInstruction extends BinaryInstruction {
10771077
final override string getImmediateString() { result = elementSize.toString() }
10781078

10791079
/**
1080-
* Gets the size of the element pointed to by the pointer, in bytes.
1080+
* Gets the size of the elements pointed to by the pointer operands, in bytes.
1081+
*
1082+
* When adding an integer offset to a pointer (`PointerAddInstruction`) or subtracting an integer
1083+
* offset from a pointer (`PointerSubInstruction`), the integer offset is multiplied by the
1084+
* element size to compute the actual number of bytes added to or subtracted from the pointer
1085+
* address. When computing the integer difference between two pointers (`PointerDiffInstruction`),
1086+
* the result is computed by computing the difference between the two pointer byte addresses, then
1087+
* dividing that byte count by the element size.
10811088
*/
10821089
final int getElementSize() { result = elementSize }
10831090
}

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,14 @@ class PointerArithmeticInstruction extends BinaryInstruction {
10771077
final override string getImmediateString() { result = elementSize.toString() }
10781078

10791079
/**
1080-
* Gets the size of the element pointed to by the pointer, in bytes.
1080+
* Gets the size of the elements pointed to by the pointer operands, in bytes.
1081+
*
1082+
* When adding an integer offset to a pointer (`PointerAddInstruction`) or subtracting an integer
1083+
* offset from a pointer (`PointerSubInstruction`), the integer offset is multiplied by the
1084+
* element size to compute the actual number of bytes added to or subtracted from the pointer
1085+
* address. When computing the integer difference between two pointers (`PointerDiffInstruction`),
1086+
* the result is computed by computing the difference between the two pointer byte addresses, then
1087+
* dividing that byte count by the element size.
10811088
*/
10821089
final int getElementSize() { result = elementSize }
10831090
}

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,14 @@ class PointerArithmeticInstruction extends BinaryInstruction {
10771077
final override string getImmediateString() { result = elementSize.toString() }
10781078

10791079
/**
1080-
* Gets the size of the element pointed to by the pointer, in bytes.
1080+
* Gets the size of the elements pointed to by the pointer operands, in bytes.
1081+
*
1082+
* When adding an integer offset to a pointer (`PointerAddInstruction`) or subtracting an integer
1083+
* offset from a pointer (`PointerSubInstruction`), the integer offset is multiplied by the
1084+
* element size to compute the actual number of bytes added to or subtracted from the pointer
1085+
* address. When computing the integer difference between two pointers (`PointerDiffInstruction`),
1086+
* the result is computed by computing the difference between the two pointer byte addresses, then
1087+
* dividing that byte count by the element size.
10811088
*/
10821089
final int getElementSize() { result = elementSize }
10831090
}

0 commit comments

Comments
 (0)