Skip to content

Commit aecc17c

Browse files
authored
Merge pull request #7928 from jketema/structured-bindings-db-scheme
C++: Add table that identifies C++ structured bindings
2 parents 31d214d + fc91c82 commit aecc17c

File tree

10 files changed

+8409
-0
lines changed

10 files changed

+8409
-0
lines changed

cpp/downgrades/bb0f279f2acd793105a347d589b5afc8715d94c4/old.dbscheme

Lines changed: 2096 additions & 0 deletions
Large diffs are not rendered by default.

cpp/downgrades/bb0f279f2acd793105a347d589b5afc8715d94c4/semmlecode.cpp.dbscheme

Lines changed: 2095 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
description: Add relation for tracking variables from structured binding declarations
2+
compatibility: full
3+
is_structured_binding.rel: delete
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: feature
3+
---
4+
* Added a `isStructuredBinding` predicate to the `Variable` class which holds when the variable is declared as part of a structured binding declaration.

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ class Variable extends Declaration, @variable {
169169
variable_instantiation(underlyingElement(this), unresolveElement(v))
170170
}
171171

172+
/**
173+
* Holds if this variable is declated as part of a structured binding
174+
* declaration. For example, `x` in `auto [x, y] = ...`.
175+
*/
176+
predicate isStructuredBinding() { is_structured_binding(underlyingElement(this)) }
177+
172178
/**
173179
* Holds if this is a compiler-generated variable. For example, a
174180
* [range-based for loop](http://en.cppreference.com/w/cpp/language/range-for)

cpp/ql/lib/semmlecode.cpp.dbscheme

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ var_decl_specifiers(
446446
int id: @var_decl ref,
447447
string name: string ref
448448
)
449+
is_structured_binding(unique int id: @variable ref);
449450

450451
type_decls(
451452
unique int id: @type_decl,

cpp/ql/lib/semmlecode.cpp.dbscheme.stats

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14877,6 +14877,17 @@
1487714877
</dependencies>
1487814878
</relation>
1487914879
<relation>
14880+
<name>is_structured_binding</name>
14881+
<cardinality>10</cardinality>
14882+
<columnsizes>
14883+
<e>
14884+
<k>id</k>
14885+
<v>10</v>
14886+
</e>
14887+
</columnsizes>
14888+
<dependencies/>
14889+
</relation>
14890+
<relation>
1488014891
<name>type_decls</name>
1488114892
<cardinality>1316547</cardinality>
1488214893
<columnsizes>

0 commit comments

Comments
 (0)