Skip to content

Commit d956bf9

Browse files
committed
C++: Document the three predicates for array size
1 parent b6b3581 commit d956bf9

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

cpp/ql/src/semmle/code/cpp/Type.qll

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -904,15 +904,26 @@ class ArrayType extends DerivedType {
904904
ArrayType() { derivedtypes(underlyingElement(this),_,4,_) }
905905

906906
predicate hasArraySize() { arraysizes(underlyingElement(this),_,_,_) }
907+
908+
/**
909+
* Gets the number of elements in this array. Only has a result for arrays declared to be of a
910+
* constant size. See `getByteSize` for getting the number of bytes.
911+
*/
907912
int getArraySize() { arraysizes(underlyingElement(this),result,_,_) }
908913

914+
/**
915+
* Gets the byte size of this array. Only has a result for arrays declared to be of a constant
916+
* size. This predicate is a synonym for `getByteSize`. See `getArraySize` for getting the number
917+
* of elements.
918+
*/
909919
int getByteSize() { arraysizes(underlyingElement(this),_,result,_) }
910920

911921
override int getAlignment() { arraysizes(underlyingElement(this), _, _, result) }
912922

913923
/**
914-
* Gets the size of this array (only valid for arrays declared to be of a constant
915-
* size, will fail for all others).
924+
* Gets the byte size of this array. Only has a result for arrays declared to be of a constant
925+
* size. This predicate is a synonym for `getByteSize`. See `getArraySize` for getting the number
926+
* of elements.
916927
*/
917928
override int getSize() {
918929
result = this.getByteSize()

0 commit comments

Comments
 (0)