From d956bf90ade4d7b3b41d217f8b3d144639ff86b4 Mon Sep 17 00:00:00 2001 From: Jonas Jensen Date: Tue, 11 Sep 2018 15:15:44 +0200 Subject: [PATCH 1/2] C++: Document the three predicates for array size --- cpp/ql/src/semmle/code/cpp/Type.qll | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/cpp/ql/src/semmle/code/cpp/Type.qll b/cpp/ql/src/semmle/code/cpp/Type.qll index e3df04abb5aa..2d6176b7d7a7 100644 --- a/cpp/ql/src/semmle/code/cpp/Type.qll +++ b/cpp/ql/src/semmle/code/cpp/Type.qll @@ -904,15 +904,26 @@ class ArrayType extends DerivedType { ArrayType() { derivedtypes(underlyingElement(this),_,4,_) } predicate hasArraySize() { arraysizes(underlyingElement(this),_,_,_) } + + /** + * Gets the number of elements in this array. Only has a result for arrays declared to be of a + * constant size. See `getByteSize` for getting the number of bytes. + */ int getArraySize() { arraysizes(underlyingElement(this),result,_,_) } + /** + * Gets the byte size of this array. Only has a result for arrays declared to be of a constant + * size. This predicate is a synonym for `getByteSize`. See `getArraySize` for getting the number + * of elements. + */ int getByteSize() { arraysizes(underlyingElement(this),_,result,_) } override int getAlignment() { arraysizes(underlyingElement(this), _, _, result) } /** - * Gets the size of this array (only valid for arrays declared to be of a constant - * size, will fail for all others). + * Gets the byte size of this array. Only has a result for arrays declared to be of a constant + * size. This predicate is a synonym for `getByteSize`. See `getArraySize` for getting the number + * of elements. */ override int getSize() { result = this.getByteSize() From 4304a4e1bc7f57aabb570a80ccbd2b598200d0ac Mon Sep 17 00:00:00 2001 From: Jonas Jensen Date: Tue, 11 Sep 2018 15:39:44 +0200 Subject: [PATCH 2/2] C++: Fix docs copy-paste error --- cpp/ql/src/semmle/code/cpp/Type.qll | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cpp/ql/src/semmle/code/cpp/Type.qll b/cpp/ql/src/semmle/code/cpp/Type.qll index 2d6176b7d7a7..060d7a27e976 100644 --- a/cpp/ql/src/semmle/code/cpp/Type.qll +++ b/cpp/ql/src/semmle/code/cpp/Type.qll @@ -913,8 +913,7 @@ class ArrayType extends DerivedType { /** * Gets the byte size of this array. Only has a result for arrays declared to be of a constant - * size. This predicate is a synonym for `getByteSize`. See `getArraySize` for getting the number - * of elements. + * size. See `getArraySize` for getting the number of elements. */ int getByteSize() { arraysizes(underlyingElement(this),_,result,_) }