mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
C++: Fix the suppression for alerts about enums
The suppression mechanism broke when I changed `relOpWithSwap` to take fully-converted expressions as parameters.
This commit is contained in:
@@ -38,7 +38,7 @@ where
|
||||
// a comparison between an enum and zero is always valid because whether
|
||||
// the underlying type of an enum is signed is compiler-dependent
|
||||
not exists (Expr e, ConstantZero z
|
||||
| relOpWithSwap(cmp, e, z, _, _) and
|
||||
| relOpWithSwap(cmp, e.getFullyConverted(), z, _, _) and
|
||||
e.getUnderlyingType() instanceof Enum) and
|
||||
|
||||
// Construct a reason for the message. Something like: x >= 5 and 3 >= y.
|
||||
|
||||
@@ -207,7 +207,7 @@ enum my_enum {
|
||||
};
|
||||
|
||||
int myFunction6(enum my_enum e) {
|
||||
if (e < 0) { // BAD
|
||||
if (e < 0) { // GOOD (suppressed because it's platform-dependent)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
| PointlessComparison.c:126:12:126:18 | ... >= ... | Comparison is always true because a >= 20. |
|
||||
| PointlessComparison.c:129:12:129:16 | ... > ... | Comparison is always false because a <= 3. |
|
||||
| PointlessComparison.c:197:7:197:11 | ... < ... | Comparison is always false because x >= 0. |
|
||||
| PointlessComparison.c:210:6:210:10 | ... < ... | Comparison is always false because e >= 0. |
|
||||
| PointlessComparison.c:264:12:264:22 | ... >= ... | Comparison is always true because dbl >= 0 and -0 >= - .... |
|
||||
| PointlessComparison.c:273:9:273:18 | ... > ... | Comparison is always false because c <= 0. |
|
||||
| PointlessComparison.c:283:13:283:19 | ... >= ... | Comparison is always true because c >= 11. |
|
||||
|
||||
Reference in New Issue
Block a user