1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 * A script for GCC-dehydra to analyze the Mozilla codebase and catch
7 * patterns that are incorrect, but which cannot be detected by a compiler. */
10 * Activate Treehydra outparams analysis if running in Treehydra.
13 function treehydra_enabled() {
14 return this.hasOwnProperty('TREE_CODE');
17 sys.include_path.push(options.topsrcdir);
19 include('string-format.js');
23 function LoadModules(modulelist)
28 let modulenames = modulelist.split(',');
29 for each (let modulename in modulenames) {
30 let module = { __proto__: this };
31 include(modulename, module);
36 LoadModules(options['dehydra-modules']);
37 if (treehydra_enabled())
38 LoadModules(options['treehydra-modules']);
40 function process_type(c)
42 for each (let module in modules)
43 if (module.hasOwnProperty('process_type'))
44 module.process_type(c);
47 function hasAttribute(c, attrname)
51 if (c.attributes === undefined)
54 for each (attr in c.attributes)
55 if (attr.name == 'user' && attr.value[0] == attrname)
61 // This is useful for detecting method overrides
62 function signaturesMatch(m1, m2)
64 if (m1.shortName != m2.shortName)
67 if ((!!m1.isVirtual) != (!!m2.isVirtual))
70 if (m1.isStatic != m2.isStatic)
73 let p1 = m1.type.parameters;
74 let p2 = m2.type.parameters;
76 if (p1.length != p2.length)
79 for (let i = 0; i < p1.length; ++i)
80 if (!params_match(p1[i], p2[i]))
86 function params_match(p1, p2)
88 [p1, p2] = unwrap_types(p1, p2);
91 if (i == "type" && !types_match(p1.type, p2.type))
93 else if (i != "type" && p1[i] !== p2[i])
103 function types_match(t1, t2)
108 [t1, t2] = unwrap_types(t1, t2);
113 function unwrap_types(t1, t2)
124 const forward_functions = [
131 'process_cp_pre_genericize',
135 function setup_forwarding(n)
137 this[n] = function() {
138 for each (let module in modules) {
139 if (module.hasOwnProperty(n)) {
140 module[n].apply(this, arguments);
146 for each (let n in forward_functions)