Skip to content
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 changes: 2 additions & 0 deletions change_notes/2026-08-19-allow-structured-bindings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `RULE-10-0-1`, `M8-0-1` - `MultipleLocalDeclarators.qll`:
- Added a check to ignore structured bindings from C++17, which are explicitly allowed by RULE 10-0-1 and serve a unique useful purpose.
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ query predicate problems(DeclStmt ds, string message) {
count(Declaration d | d = ds.getADeclaration()) > 1 and
// Not a compiler generated `DeclStmt`, such as in the range-based for loop
not ds.isCompilerGenerated() and
// Not a structured binding
not ds.getADeclaration().(Variable).isStructuredBinding() and
message = "Declaration list contains more than one declaration."
}
6 changes: 6 additions & 0 deletions cpp/common/test/rules/multiplelocaldeclarators/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,10 @@ void test_loop(std::vector<ClassA> v) {
for (const auto b : v) { // COMPLIANT - DeclStmt is compiler generated
b;
}
}

#include <utility>
void f2() {
std::pair<int, int> p1;
auto [a, b] = p1; // COMPLIANT - structured bindings.
}
Loading