@@ -8,168 +8,41 @@ import semmle.code.cpp.AutogeneratedFile
88predicate trivialPositiveIntValue ( string s ) {
99 // Small numbers
1010 s = [ 0 .. 20 ] .toString ( ) or
11- // Popular powers of two (decimal)
12- s = "16" or
13- s = "24" or
14- s = "32" or
15- s = "64" or
16- s = "128" or
17- s = "256" or
18- s = "512" or
19- s = "1024" or
20- s = "2048" or
21- s = "4096" or
22- s = "16384" or
23- s = "32768" or
24- s = "65536" or
25- s = "1048576" or
26- s = "2147483648" or
27- s = "4294967296" or
28- // Popular powers of two, minus one (decimal)
29- s = "15" or
30- s = "31" or
31- s = "63" or
32- s = "127" or
33- s = "255" or
34- s = "511" or
35- s = "1023" or
36- s = "2047" or
37- s = "4095" or
38- s = "16383" or
39- s = "32767" or
40- s = "65535" or
41- s = "1048577" or
42- s = "2147483647" or
43- s = "4294967295" or
44- // Popular powers of two (32-bit hex)
45- s = "0x00000001" or
46- s = "0x00000002" or
47- s = "0x00000004" or
48- s = "0x00000008" or
49- s = "0x00000010" or
50- s = "0x00000020" or
51- s = "0x00000040" or
52- s = "0x00000080" or
53- s = "0x00000100" or
54- s = "0x00000200" or
55- s = "0x00000400" or
56- s = "0x00000800" or
57- s = "0x00001000" or
58- s = "0x00002000" or
59- s = "0x00004000" or
60- s = "0x00008000" or
61- s = "0x00010000" or
62- s = "0x00020000" or
63- s = "0x00040000" or
64- s = "0x00080000" or
65- s = "0x00100000" or
66- s = "0x00200000" or
67- s = "0x00400000" or
68- s = "0x00800000" or
69- s = "0x01000000" or
70- s = "0x02000000" or
71- s = "0x04000000" or
72- s = "0x08000000" or
73- s = "0x10000000" or
74- s = "0x20000000" or
75- s = "0x40000000" or
76- s = "0x80000000" or
77- // Popular powers of two, minus one (32-bit hex)
78- s = "0x00000001" or
79- s = "0x00000003" or
80- s = "0x00000007" or
81- s = "0x0000000f" or
82- s = "0x0000001f" or
83- s = "0x0000003f" or
84- s = "0x0000007f" or
85- s = "0x000000ff" or
86- s = "0x000001ff" or
87- s = "0x000003ff" or
88- s = "0x000007ff" or
89- s = "0x00000fff" or
90- s = "0x00001fff" or
91- s = "0x00003fff" or
92- s = "0x00007fff" or
93- s = "0x0000ffff" or
94- s = "0x0001ffff" or
95- s = "0x0003ffff" or
96- s = "0x0007ffff" or
97- s = "0x000fffff" or
98- s = "0x001fffff" or
99- s = "0x003fffff" or
100- s = "0x007fffff" or
101- s = "0x00ffffff" or
102- s = "0x01ffffff" or
103- s = "0x03ffffff" or
104- s = "0x07ffffff" or
105- s = "0x0fffffff" or
106- s = "0x1fffffff" or
107- s = "0x3fffffff" or
108- s = "0x7fffffff" or
109- s = "0xffffffff" or
110- // Popular powers of two (16-bit hex)
111- s = "0x0001" or
112- s = "0x0002" or
113- s = "0x0004" or
114- s = "0x0008" or
115- s = "0x0010" or
116- s = "0x0020" or
117- s = "0x0040" or
118- s = "0x0080" or
119- s = "0x0100" or
120- s = "0x0200" or
121- s = "0x0400" or
122- s = "0x0800" or
123- s = "0x1000" or
124- s = "0x2000" or
125- s = "0x4000" or
126- s = "0x8000" or
127- // Popular powers of two, minus one (16-bit hex)
128- s = "0x0001" or
129- s = "0x0003" or
130- s = "0x0007" or
131- s = "0x000f" or
132- s = "0x001f" or
133- s = "0x003f" or
134- s = "0x007f" or
135- s = "0x00ff" or
136- s = "0x01ff" or
137- s = "0x03ff" or
138- s = "0x07ff" or
139- s = "0x0fff" or
140- s = "0x1fff" or
141- s = "0x3fff" or
142- s = "0x7fff" or
143- s = "0xffff" or
144- // Popular powers of two (8-bit hex)
145- s = "0x01" or
146- s = "0x02" or
147- s = "0x04" or
148- s = "0x08" or
149- s = "0x10" or
150- s = "0x20" or
151- s = "0x40" or
152- s = "0x80" or
153- // Popular powers of two, minus one (8-bit hex)
154- s = "0x01" or
155- s = "0x03" or
156- s = "0x07" or
157- s = "0x0f" or
158- s = "0x1f" or
159- s = "0x3f" or
160- s = "0x7f" or
161- s = "0xff" or
162- s = "0x00" or
163- // Powers of ten
164- s = "10" or
165- s = "100" or
166- s = "1000" or
167- s = "10000" or
168- s = "100000" or
169- s = "1000000" or
170- s = "10000000" or
171- s = "100000000" or
172- s = "1000000000"
11+ s =
12+ [
13+ // Popular powers of two (decimal)
14+ "16" , "24" , "32" , "64" , "128" , "256" , "512" , "1024" , "2048" , "4096" , "16384" , "32768" ,
15+ "65536" , "1048576" , "2147483648" , "4294967296" ,
16+ // Popular powers of two, minus one (decimal)
17+ "15" , "31" , "63" , "127" , "255" , "511" , "1023" , "2047" , "4095" , "16383" , "32767" , "65535" ,
18+ "1048577" , "2147483647" , "4294967295" ,
19+ // Popular powers of two (32-bit hex)
20+ "0x00000001" , "0x00000002" , "0x00000004" , "0x00000008" , "0x00000010" , "0x00000020" ,
21+ "0x00000040" , "0x00000080" , "0x00000100" , "0x00000200" , "0x00000400" , "0x00000800" ,
22+ "0x00001000" , "0x00002000" , "0x00004000" , "0x00008000" , "0x00010000" , "0x00020000" ,
23+ "0x00040000" , "0x00080000" , "0x00100000" , "0x00200000" , "0x00400000" , "0x00800000" ,
24+ "0x01000000" , "0x02000000" , "0x04000000" , "0x08000000" , "0x10000000" , "0x20000000" ,
25+ "0x40000000" , "0x80000000" ,
26+ // Popular powers of two, minus one (32-bit hex)
27+ "0x00000001" , "0x00000003" , "0x00000007" , "0x0000000f" , "0x0000001f" , "0x0000003f" ,
28+ "0x0000007f" , "0x000000ff" , "0x000001ff" , "0x000003ff" , "0x000007ff" , "0x00000fff" ,
29+ "0x00001fff" , "0x00003fff" , "0x00007fff" , "0x0000ffff" , "0x0001ffff" , "0x0003ffff" ,
30+ "0x0007ffff" , "0x000fffff" , "0x001fffff" , "0x003fffff" , "0x007fffff" , "0x00ffffff" ,
31+ "0x01ffffff" , "0x03ffffff" , "0x07ffffff" , "0x0fffffff" , "0x1fffffff" , "0x3fffffff" ,
32+ "0x7fffffff" , "0xffffffff" ,
33+ // Popular powers of two (16-bit hex)
34+ "0x0001" , "0x0002" , "0x0004" , "0x0008" , "0x0010" , "0x0020" , "0x0040" , "0x0080" , "0x0100" ,
35+ "0x0200" , "0x0400" , "0x0800" , "0x1000" , "0x2000" , "0x4000" , "0x8000" ,
36+ // Popular powers of two, minus one (16-bit hex)
37+ "0x0001" , "0x0003" , "0x0007" , "0x000f" , "0x001f" , "0x003f" , "0x007f" , "0x00ff" , "0x01ff" ,
38+ "0x03ff" , "0x07ff" , "0x0fff" , "0x1fff" , "0x3fff" , "0x7fff" , "0xffff" ,
39+ // Popular powers of two (8-bit hex)
40+ "0x01" , "0x02" , "0x04" , "0x08" , "0x10" , "0x20" , "0x40" , "0x80" ,
41+ // Popular powers of two, minus one (8-bit hex)
42+ "0x01" , "0x03" , "0x07" , "0x0f" , "0x1f" , "0x3f" , "0x7f" , "0xff" , "0x00" ,
43+ // Powers of ten
44+ "10" , "100" , "1000" , "10000" , "100000" , "1000000" , "10000000" , "100000000" , "1000000000"
45+ ]
17346}
17447
17548predicate trivialIntValue ( string s ) {
@@ -235,10 +108,7 @@ predicate joiningStringTrivial(Literal lit) {
235108 // understand (which is against the spirit of these queries).
236109 stringLiteral ( lit ) and
237110 exists ( FunctionCall fc |
238- (
239- fc .getTarget ( ) .getName ( ) = "operator+" or
240- fc .getTarget ( ) .getName ( ) = "operator<<"
241- ) and
111+ fc .getTarget ( ) .getName ( ) = [ "operator+" , "operator<<" ] and
242112 fc .getAnArgument ( ) .getAChild * ( ) = lit
243113 ) and
244114 lit .getValue ( ) .length ( ) < 16
0 commit comments