Skip to content

Commit e00e450

Browse files
committed
Fix(common/cpp): useless assignment false positive on constexpr array size.
1 parent c4dafe7 commit e00e450

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- `A0-1-1` - `UselessAssignments.qll`:
2+
- Remove (dead code) useless assignment false positive when integer constant expression is used to define the size of an array.

cpp/common/src/codingstandards/cpp/deadcode/UselessAssignments.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44

55
import cpp
6+
import codingstandards.cpp.deadcode.UnusedVariables
67
import codingstandards.cpp.enhancements.ControlFlowGraphEnhancements
78

89
/** If a variable may escape from the local context */
@@ -47,7 +48,9 @@ class InterestingStackVariable extends StackVariable {
4748
// Ignore variables in uninstantiated templates
4849
not this.isFromUninstantiatedTemplate(_) and
4950
// Ignore compiler generated variables, such as those generated for range based for loops
50-
not this.isCompilerGenerated()
51+
not this.isCompilerGenerated() and
52+
// Explicitly ignore (propagated) constants that may be used to define sizes of local arrays
53+
not countUsesInLocalArraySize(this) > 0
5154
}
5255
}
5356

0 commit comments

Comments
 (0)