Skip to content

C++: add isVla predicated to ArrayType #19298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,446 changes: 2,446 additions & 0 deletions cpp/downgrades/0f0a390468a5eb43d1dc72937c028070b106bf53/old.dbscheme

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
description: Add a new predicate `isVla()` to the `ArrayType` class
compatibility: full
type_is_vla.rel: delete
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
category: feature
---
* Added the `isVla()` predicate to the `ArrayType` class. This allows queries to identify variable-length arrays (VLAs).
5 changes: 5 additions & 0 deletions cpp/ql/lib/semmle/code/cpp/Type.qll
Original file line number Diff line number Diff line change
Expand Up @@ -1369,6 +1369,11 @@ class ArrayType extends DerivedType {
override predicate isDeeplyConst() { this.getBaseType().isDeeplyConst() } // No such thing as a const array type

override predicate isDeeplyConstBelow() { this.getBaseType().isDeeplyConst() }

/**
* Holds if this array is a variable-length array (VLA).
*/
predicate isVla() { type_is_vla(underlyingElement(this)) }
}

/**
Expand Down
2 changes: 2 additions & 0 deletions cpp/ql/lib/semmlecode.cpp.dbscheme
Original file line number Diff line number Diff line change
Expand Up @@ -2178,6 +2178,8 @@ variable_vla(
int decl: @stmt_vla_decl ref
);

type_is_vla(unique int type_id: @derivedtype ref)

if_initialization(
unique int if_stmt: @stmt_if ref,
int init_id: @stmt ref
Expand Down
Loading