2 * A script for GCC-dehydra to analyze the Mozilla codebase and catch
3 * patterns that are incorrect, but which cannot be detected by a compiler. */
6 * Activate Treehydra outparams analysis if running in Treehydra.
9 function treehydra_enabled() {
10 return this.hasOwnProperty('TREE_CODE');
13 sys.include_path.push(options.topsrcdir);
15 include('string-format.js');
19 function LoadModules(modulelist)
24 let modulenames = modulelist.split(',');
25 for each (let modulename in modulenames) {
26 let module = { __proto__: this };
27 include(modulename, module);
32 LoadModules(options['dehydra-modules']);
33 if (treehydra_enabled())
34 LoadModules(options['treehydra-modules']);
36 function process_type(c)
38 for each (let module in modules)
39 if (module.hasOwnProperty('process_type'))
40 module.process_type(c);
43 function hasAttribute(c, attrname)
47 if (c.attributes === undefined)
50 for each (attr in c.attributes)
51 if (attr.name == 'user' && attr.value[0] == attrname)
57 // This is useful for detecting method overrides
58 function signaturesMatch(m1, m2)
60 if (m1.shortName != m2.shortName)
63 if ((!!m1.isVirtual) != (!!m2.isVirtual))
66 if (m1.isStatic != m2.isStatic)
69 let p1 = m1.type.parameters;
70 let p2 = m2.type.parameters;
72 if (p1.length != p2.length)
75 for (let i = 0; i < p1.length; ++i)
76 if (!params_match(p1[i], p2[i]))
82 function params_match(p1, p2)
84 [p1, p2] = unwrap_types(p1, p2);
87 if (i == "type" && !types_match(p1.type, p2.type))
89 else if (i != "type" && p1[i] !== p2[i])
99 function types_match(t1, t2)
104 [t1, t2] = unwrap_types(t1, t2);
109 function unwrap_types(t1, t2)
120 const forward_functions = [
127 'process_cp_pre_genericize',
131 function setup_forwarding(n)
133 this[n] = function() {
134 for each (let module in modules) {
135 if (module.hasOwnProperty(n)) {
136 module[n].apply(this, arguments);
142 for each (let n in forward_functions)