Build fix (followup to bug 512029).
[mozilla-central.git] / config / static-checking.js
blob5159266df06ebe946ef5e9cd60425666b39308cc
1 /**
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. */
5 /**
6  * Activate Treehydra outparams analysis if running in Treehydra.
7  */
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');
20 let modules = [];
22 function LoadModules(modulelist)
24   if (modulelist == "")
25     return;
27   let modulenames = modulelist.split(',');
28   for each (let modulename in modulenames) {
29     let module = { __proto__: this };
30     include(modulename, module);
31     modules.push(module);
32   }
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)
48   var attr;
50   if (c.attributes === undefined)
51     return false;
53   for each (attr in c.attributes)
54     if (attr.name == 'user' && attr.value[0] == attrname)
55       return true;
57   return false;
60 const forward_functions = [
61   'process_type',
62   'process_tree_type',
63   'process_decl',
64   'process_tree_decl',
65   'process_function',
66   'process_tree',
67   'process_cp_pre_genericize',
68   'input_end'
71 function setup_forwarding(n)
73   this[n] = function() {
74     for each (let module in modules) {
75       if (module.hasOwnProperty(n)) {
76         module[n].apply(this, arguments);
77       }
78     }
79   }
82 for each (let n in forward_functions)
83   setup_forwarding(n);