File tree Expand file tree Collapse file tree 3 files changed +10
-8
lines changed
src/codingstandards/cpp/deadcode Expand file tree Collapse file tree 3 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -161,8 +161,10 @@ string getConstExprValue(Variable v) {
161
161
* Counts uses of `Variable` v in a local array of size `n`
162
162
*/
163
163
int countUsesInLocalArraySize ( Variable v ) {
164
- result = count ( ArrayType at , LocalVariable arrayVariable |
165
- arrayVariable .getType ( ) .resolveTypedefs ( ) = at and
166
- v .( PotentiallyUnusedLocalVariable ) .getFunction ( ) = arrayVariable .getFunction ( ) and
167
- at .getArraySize ( ) .toString ( ) = getConstExprValue ( v ) )
164
+ result =
165
+ count ( ArrayType at , LocalVariable arrayVariable |
166
+ arrayVariable .getType ( ) .resolveTypedefs ( ) = at and
167
+ v .( PotentiallyUnusedLocalVariable ) .getFunction ( ) = arrayVariable .getFunction ( ) and
168
+ at .getArraySize ( ) .toString ( ) = getConstExprValue ( v )
169
+ )
168
170
}
Original file line number Diff line number Diff line change 12
12
| test.cpp:72:3:73:3 | try { ... } | This statement is dead code. |
13
13
| test.cpp:73:17:74:3 | { ... } | This statement is dead code. |
14
14
| test.cpp:79:17:80:3 | { ... } | This statement is dead code. |
15
- | test.cpp:85:3:85:44 | declaration | This statement is dead code. |
15
+ | test.cpp:85:3:85:43 | declaration | This statement is dead code. |
16
16
| test.cpp:87:3:87:30 | declaration | This statement is dead code. |
17
17
| test.cpp:90:3:90:50 | declaration | This statement is dead code. |
Original file line number Diff line number Diff line change @@ -81,12 +81,12 @@ int test_dead_code(int x) {
81
81
82
82
static_assert (1 ); // COMPLIANT
83
83
84
- constexpr int constexpr_array_size{6 }; // COMPLIANT
85
- int unused_array[constexpr_array_size] {}; // NON_COMPLIANT
84
+ constexpr int constexpr_array_size{6 }; // COMPLIANT
85
+ int unused_array[constexpr_array_size]{}; // NON_COMPLIANT
86
86
87
87
constexpr int unused_int{2 }; // NON_COMPLIANT
88
88
89
- constexpr int constexpr_used_array[]{3 , 4 , 5 }; // COMPLIANT
89
+ constexpr int constexpr_used_array[]{3 , 4 , 5 }; // COMPLIANT
90
90
constexpr int constexpr_unused_array[]{0 , 1 , 2 }; // NON_COMPLIANT
91
91
92
92
return live5 + live6 + constexpr_used_array[1 ]; // COMPLIANT
You can’t perform that action at this time.
0 commit comments