Skip to content

Commit 67bfe10

Browse files
authored
Merge pull request #19298 from github/idrissrio/vla
C++: add `isVla` predicated to `ArrayType`
2 parents 29be217 + 202040f commit 67bfe10

File tree

10 files changed

+11056
-1244
lines changed

10 files changed

+11056
-1244
lines changed

cpp/downgrades/0f0a390468a5eb43d1dc72937c028070b106bf53/old.dbscheme

+2,446
Large diffs are not rendered by default.

cpp/downgrades/0f0a390468a5eb43d1dc72937c028070b106bf53/semmlecode.cpp.dbscheme

+2,444
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
description: Add a new predicate `isVla()` to the `ArrayType` class
2+
compatibility: full
3+
type_is_vla.rel: delete
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: feature
3+
---
4+
* Added the `isVla()` predicate to the `ArrayType` class. This allows queries to identify variable-length arrays (VLAs).

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

+5
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

+2
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: @derivedtype ref)
2182+
21812183
if_initialization(
21822184
unique int if_stmt: @stmt_if ref,
21832185
int init_id: @stmt ref

0 commit comments

Comments
 (0)