Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ predicate declarationHasSideEffects(Variable v) {
from Variable v
where
v.isStatic() and
not v.isCompilerGenerated() and
v.hasDefinition() and
not v.isConstexpr() and
not exists(VariableAccess a | a.getTarget() = v) and
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* The `cpp/unused-static-variable` query no longer reports compiler-generated variables, such as placeholders for empty function parameter packs.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// semmle-extractor-options: -std=c++17
// semmle-extractor-options: -std=c++20
int globalVar; // GOOD (not static)
static int staticVar1; // GOOD (used)
static int staticVar2; // GOOD (used)
Expand Down Expand Up @@ -49,3 +49,10 @@ struct WithDestructor

static WithConstructor constructed; // GOOD (constructor has a side effect)
static WithDestructor destructed; // GOOD (destructor has a side effect)

static auto sum(auto... values)
{
return (0 + ... + values);
}

int globalVar2 = sum() + sum(2);
Loading