@@ -89,44 +89,32 @@ def main():
89
89
# alloc_fns contains all the vanilla allocation/free functions that we look
90
90
# for. Regexp chars are escaped appropriately.
91
91
92
- operator_news = [
92
+ alloc_fns = [
93
93
# Matches |operator new(unsigned T)|, where |T| is |int| or |long|.
94
- r"operator new(unsigned" ,
94
+ r"operator new\ (unsigned" ,
95
95
# Matches |operator new[](unsigned T)|, where |T| is |int| or |long|.
96
- r"operator new[](unsigned" ,
96
+ r"operator new\[\]\(unsigned" ,
97
+ r"memalign" ,
98
+ # These three aren't available on all Linux configurations.
99
+ # r'posix_memalign',
100
+ # r'aligned_alloc',
101
+ # r'valloc',
97
102
]
98
103
99
- # operator new may end up inlined and replaced with moz_xmalloc.
100
- inlined_operator_news = [
101
- r"moz_xmalloc" ,
102
- ]
103
-
104
- alloc_fns = (
105
- operator_news
106
- + inlined_operator_news
107
- + [
108
- r"memalign" ,
109
- # These three aren't available on all Linux configurations.
110
- # r'posix_memalign',
111
- # r'aligned_alloc',
112
- # r'valloc',
113
- ]
114
- )
115
-
116
104
if args .aggressive :
117
105
alloc_fns += [r"malloc" , r"calloc" , r"realloc" , r"free" , r"strdup" ]
118
106
119
107
# This is like alloc_fns, but regexp chars are not escaped.
120
- alloc_fns_escaped = [re . escape ( fn ) for fn in alloc_fns ]
108
+ alloc_fns_unescaped = [fn . replace ( " \\ " , "" ) for fn in alloc_fns ]
121
109
122
110
# This regexp matches the relevant lines in the output of |nm|, which look
123
111
# like the following.
124
112
#
125
113
# js/src/libjs_static.a:Utility.o: U malloc
126
114
# js/src/libjs_static.a:Utility.o: 00000000000007e0 T js::SetSourceOptions(...)
127
115
#
128
- nm_line_re = re .compile (r"([^:/ ]+):\s*[0-9a-fA-F]*\s+([TUw ]) (.*)" )
129
- alloc_fns_re = re .compile (r"|" .join (alloc_fns_escaped ))
116
+ nm_line_re = re .compile (r"([^:/ ]+):\s*[0-9a-fA-F]*\s+([TU ]) (.*)" )
117
+ alloc_fns_re = re .compile (r"|" .join (alloc_fns ))
130
118
131
119
# This tracks which allocation/free functions have been seen.
132
120
functions = defaultdict (set )
@@ -214,24 +202,9 @@ def main():
214
202
215
203
# Check that all functions we expect are used in util/Utility.cpp. (This
216
204
# will fail if the function-detection code breaks at any point.)
217
- # operator new and its inlined equivalent are mutually exclusive.
218
- has_operator_news = any (fn in operator_news for fn in util_Utility_cpp )
219
- has_inlined_operator_news = any (
220
- fn in inlined_operator_news for fn in util_Utility_cpp
221
- )
222
- if has_operator_news and has_inlined_operator_news :
223
- fail (
224
- "Both operator new and moz_xmalloc aren't expected in util/Utility.cpp at the same time"
225
- )
226
-
227
- for fn in alloc_fns :
205
+ for fn in alloc_fns_unescaped :
228
206
if fn not in util_Utility_cpp :
229
- if (
230
- (fn in operator_news and not has_inlined_operator_news )
231
- or (fn in inlined_operator_news and not has_operator_news )
232
- or (fn not in operator_news and fn not in inlined_operator_news )
233
- ):
234
- fail ("'" + fn + "' isn't used as expected in util/Utility.cpp" )
207
+ fail ("'" + fn + "' isn't used as expected in util/Utility.cpp" )
235
208
else :
236
209
util_Utility_cpp .remove (fn )
237
210
@@ -267,9 +240,7 @@ def main():
267
240
#
268
241
# U malloc util/Utility.cpp:117
269
242
#
270
- alloc_lines_re = (
271
- r"[Uw] ((" + r"|" .join (alloc_fns_escaped ) + r").*)\s+(\S+:\d+)$"
272
- )
243
+ alloc_lines_re = r"U ((" + r"|" .join (alloc_fns ) + r").*)\s+(\S+:\d+)$"
273
244
274
245
for line in lines :
275
246
m = re .search (alloc_lines_re , line )
0 commit comments