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 include('unstable/getopt.js');
14 [options, args] = getopt();
16 sys.include_path.push(options.topsrcdir);
18 include('string-format.js');
22 function LoadModules(modulelist)
27 let modulenames = modulelist.split(',');
28 for each (let modulename in modulenames) {
29 let module = { __proto__: this };
30 include(modulename, module);
35 LoadModules(options['dehydra-modules']);
36 if (treehydra_enabled())
37 LoadModules(options['treehydra-modules']);
39 function process_type(c)
41 for each (let module in modules)
42 if (module.hasOwnProperty('process_type'))
43 module.process_type(c);
46 function hasAttribute(c, attrname)
50 if (c.attributes === undefined)
53 for each (attr in c.attributes)
54 if (attr.name == 'user' && attr.value[0] == attrname)
60 // This is useful for detecting method overrides
61 function signaturesMatch(m1, m2)
63 if (m1.shortName != m2.shortName)
66 if ((!!m1.isVirtual) != (!!m2.isVirtual))
69 if (m1.isStatic != m2.isStatic)
72 let p1 = m1.type.parameters;
73 let p2 = m2.type.parameters;
75 if (p1.length != p2.length)
78 for (let i = 0; i < p1.length; ++i)
85 const forward_functions = [
92 'process_cp_pre_genericize',
96 function setup_forwarding(n)
98 this[n] = function() {
99 for each (let module in modules) {
100 if (module.hasOwnProperty(n)) {
101 module[n].apply(this, arguments);
107 for each (let n in forward_functions)