@@ -6,27 +6,9 @@ import semmle.code.cpp.AutogeneratedFile
66 */
77
88predicate trivialPositiveIntValue ( string s ) {
9- s = "0" or
10- s = "1" or
11- s = "2" or
12- s = "3" or
13- s = "4" or
14- s = "5" or
15- s = "6" or
16- s = "7" or
17- s = "8" or
18- s = "9" or
19- s = "10" or
20- s = "11" or
21- s = "12" or
22- s = "13" or
23- s = "14" or
24- s = "15" or
25- s = "16" or
26- s = "17" or
27- s = "18" or
28- s = "19" or
29- s = "20" or
9+ // Small numbers
10+ s = [ 0 .. 20 ] .toString ( ) or
11+ // Popular powers of two (decimal)
3012 s = "16" or
3113 s = "24" or
3214 s = "32" or
@@ -43,6 +25,7 @@ predicate trivialPositiveIntValue(string s) {
4325 s = "1048576" or
4426 s = "2147483648" or
4527 s = "4294967296" or
28+ // Popular powers of two, minus one (decimal)
4629 s = "15" or
4730 s = "31" or
4831 s = "63" or
@@ -58,6 +41,7 @@ predicate trivialPositiveIntValue(string s) {
5841 s = "1048577" or
5942 s = "2147483647" or
6043 s = "4294967295" or
44+ // Popular powers of two (32-bit hex)
6145 s = "0x00000001" or
6246 s = "0x00000002" or
6347 s = "0x00000004" or
@@ -90,6 +74,7 @@ predicate trivialPositiveIntValue(string s) {
9074 s = "0x20000000" or
9175 s = "0x40000000" or
9276 s = "0x80000000" or
77+ // Popular powers of two, minus one (32-bit hex)
9378 s = "0x00000001" or
9479 s = "0x00000003" or
9580 s = "0x00000007" or
@@ -122,6 +107,7 @@ predicate trivialPositiveIntValue(string s) {
122107 s = "0x3fffffff" or
123108 s = "0x7fffffff" or
124109 s = "0xffffffff" or
110+ // Popular powers of two (16-bit hex)
125111 s = "0x0001" or
126112 s = "0x0002" or
127113 s = "0x0004" or
@@ -138,6 +124,7 @@ predicate trivialPositiveIntValue(string s) {
138124 s = "0x2000" or
139125 s = "0x4000" or
140126 s = "0x8000" or
127+ // Popular powers of two, minus one (16-bit hex)
141128 s = "0x0001" or
142129 s = "0x0003" or
143130 s = "0x0007" or
@@ -154,6 +141,7 @@ predicate trivialPositiveIntValue(string s) {
154141 s = "0x3fff" or
155142 s = "0x7fff" or
156143 s = "0xffff" or
144+ // Popular powers of two (8-bit hex)
157145 s = "0x01" or
158146 s = "0x02" or
159147 s = "0x04" or
@@ -162,6 +150,7 @@ predicate trivialPositiveIntValue(string s) {
162150 s = "0x20" or
163151 s = "0x40" or
164152 s = "0x80" or
153+ // Popular powers of two, minus one (8-bit hex)
165154 s = "0x01" or
166155 s = "0x03" or
167156 s = "0x07" or
@@ -171,6 +160,7 @@ predicate trivialPositiveIntValue(string s) {
171160 s = "0x7f" or
172161 s = "0xff" or
173162 s = "0x00" or
163+ // Powers of ten
174164 s = "10" or
175165 s = "100" or
176166 s = "1000" or
0 commit comments