Commit 47e82f7
committed
Fix RULE-7-0-4 false positives for non-built-in operators
`InappropriateBitwiseOrShiftOperands.ql` reported operations that do not use
the built-in bitwise or shift operators, most notably the stream insertion and
extraction operators, e.g. `stream << value`.
Resolved calls to a user provided operator are modelled as `FunctionCall`s and
therefore never reach this query. The reported operations were instead the
syntactic `LShiftExpr`/`RShiftExpr` nodes emitted for uninstantiated template
bodies, where the operands are either unresolved (`unknown`, `auto &&`) or are
the non-dependent result of an already resolved overload, such as
`std::basic_ostream<char, std::char_traits<char>> &`.
The built-in bitwise and shift operators are only applicable to integral and
unscoped enumeration operands, so an operation with an operand of any other
type does not use them. The query now requires both operands to be of such a
type before reporting a violation.
This does not introduce false negatives for dependent operands, because the
template instantiations, in which the operand types are known, are still
reported.
Fixes #11771 parent 4d0376a commit 47e82f7
4 files changed
Lines changed: 90 additions & 1 deletion
File tree
- change_notes
- cpp/misra
- src/rules/RULE-7-0-4
- test/rules/RULE-7-0-4
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
Lines changed: 45 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
25 | 65 | | |
26 | 66 | | |
27 | 67 | | |
| |||
59 | 99 | | |
60 | 100 | | |
61 | 101 | | |
62 | | - | |
| 102 | + | |
| 103 | + | |
63 | 104 | | |
64 | 105 | | |
65 | 106 | | |
| |||
82 | 123 | | |
83 | 124 | | |
84 | 125 | | |
| 126 | + | |
85 | 127 | | |
86 | 128 | | |
87 | 129 | | |
| |||
90 | 132 | | |
91 | 133 | | |
92 | 134 | | |
| 135 | + | |
93 | 136 | | |
94 | 137 | | |
95 | 138 | | |
| |||
102 | 145 | | |
103 | 146 | | |
104 | 147 | | |
| 148 | + | |
105 | 149 | | |
106 | 150 | | |
107 | 151 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
171 | 208 | | |
0 commit comments