QL code and tests for C#/C++/JavaScript.

This commit is contained in:
Pavel Avgustinov
2018-08-02 17:53:23 +01:00
commit b55526aa58
10684 changed files with 581163 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
| tst.js:2:9:2:24 | (x & (1<<n)) > 0 | Sign check of a bitwise operation |
| tst.js:14:13:14:25 | (x >>> 0) > 0 | Sign check of a bitwise operation |
| tst.js:23:1:23:21 | (x & 0x ... 00) > 0 | Sign check of a bitwise operation |

View File

@@ -0,0 +1 @@
Expressions/BitwiseSignCheck.ql

View File

@@ -0,0 +1,23 @@
function bitIsSet(x, n) {
return (x & (1<<n)) > 0;
}
console.log(bitIsSet(-1, 31)); // prints 'false'
(x & 3) > 0; // this is fine
// OK
x = -1;
console.log((x | 0) > (0)); // prints 'false'
// NOT OK
console.log((x >>> 0) > 0); // prints 'true'
// OK
console.log((x << 16 >> 16) > 0); // prints 'false'
// OK
(x & 256) > 0;
// NOT OK
(x & 0x100000000) > 0;