Skip to content

Commit bced5ae

Browse files
committed
C++: add isVLA() to ArrayType to identify variable-length arrays
1 parent 8631371 commit bced5ae

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,6 +1369,11 @@ class ArrayType extends DerivedType {
13691369
override predicate isDeeplyConst() { this.getBaseType().isDeeplyConst() } // No such thing as a const array type
13701370

13711371
override predicate isDeeplyConstBelow() { this.getBaseType().isDeeplyConst() }
1372+
1373+
/**
1374+
* Holds if this array is a variable-length array (VLA).
1375+
*/
1376+
predicate isVla() { type_is_vla(underlyingElement(this)) }
13721377
}
13731378

13741379
/**

cpp/ql/lib/semmlecode.cpp.dbscheme

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2178,6 +2178,8 @@ variable_vla(
21782178
int decl: @stmt_vla_decl ref
21792179
);
21802180

2181+
type_is_vla(unique int type_id: @type ref)
2182+
21812183
if_initialization(
21822184
unique int if_stmt: @stmt_if ref,
21832185
int init_id: @stmt ref

0 commit comments

Comments
 (0)