[CPP-434] Rename everything to SignedOverflowCheck. Add .qlhelp. Deal with addition only, not subtraction.

This commit is contained in:
Ziemowit Laski
2019-10-02 12:27:16 -07:00
parent c9a9aff221
commit 8c6caf2b4e
9 changed files with 57 additions and 23 deletions

View File

@@ -1,4 +0,0 @@
| SignedComparisons.cpp:8:12:8:22 | ... < ... | Testing for signed overflow/underflow may produce undefined results. |
| SignedComparisons.cpp:11:9:11:20 | ... < ... | Testing for signed overflow/underflow may produce undefined results. |
| SignedComparisons.cpp:21:12:21:26 | ... < ... | Testing for signed overflow/underflow may produce undefined results. |
| SignedComparisons.cpp:24:9:24:23 | ... < ... | Testing for signed overflow/underflow may produce undefined results. |

View File

@@ -1 +0,0 @@
Likely Bugs/Arithmetic/SignedComparisons.ql

View File

@@ -7,9 +7,6 @@ bool cannotHoldAnother8(int n1) {
// msvc 19.22 /O2: not deleted
return n1 + 8 < n1; // BAD
}
bool canHoldPreceding16(int n1) {
return n1 - 16 < n1;
}
/* 2. Signed comparison with a narrower unsigned type. The narrower
type gets promoted to the (signed) larger type, and so the
@@ -20,9 +17,6 @@ bool cannotHoldAnotherUShort(int n1, unsigned short delta) {
// msvc 19.22 /O2: not deleted
return n1 + delta < n1; // BAD
}
bool canHoldPrecedingUShort(int n1, unsigned short delta) {
return n1 - delta < n1;
}
/* 3. Signed comparison with a non-narrower unsigned type. The
signed type gets promoted to (a possibly wider) unsigned type,
@@ -33,6 +27,3 @@ bool cannotHoldAnotherUInt(int n1, unsigned int delta) {
// msvc 19.22 /O2: not deleted
return n1 + delta < n1; // GOOD
}
bool canHoldPrecedingUInt(int n1, unsigned int delta) {
return n1 - delta < n1;
}

View File

@@ -0,0 +1,2 @@
| SignedOverflowCheck.cpp:8:12:8:22 | ... < ... | Testing for signed overflow/underflow may produce undefined results. |
| SignedOverflowCheck.cpp:18:12:18:26 | ... < ... | Testing for signed overflow/underflow may produce undefined results. |

View File

@@ -0,0 +1 @@
Likely Bugs/Arithmetic/SignedOverflowCheck.ql