Skip to content

Commit 49b8db9

Browse files
Merge pull request #180 from jbj/ArrayType-size-docs
C++: Document the three predicates for array size
2 parents 628d7b9 + 4304a4e commit 49b8db9

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -904,15 +904,25 @@ 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. See `getArraySize` for getting the number of elements.
917+
*/
909918
int getByteSize() { arraysizes(underlyingElement(this),_,result,_) }
910919

911920
override int getAlignment() { arraysizes(underlyingElement(this), _, _, result) }
912921

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

0 commit comments

Comments
 (0)