2008-02-27 19:28:13 +03:00
|
|
|
/**
|
|
|
|
* A script for GCC-dehydra to analyze the Mozilla codebase and catch
|
|
|
|
* patterns that are incorrect, but which cannot be detected by a compiler. */
|
|
|
|
|
2008-05-01 04:47:27 +04:00
|
|
|
/**
|
|
|
|
* Activate Treehydra outparams analysis if running in Treehydra.
|
|
|
|
*/
|
|
|
|
|
|
|
|
function treehydra_enabled() {
|
|
|
|
return this.hasOwnProperty('TREE_CODE');
|
|
|
|
}
|
|
|
|
|
2008-06-06 23:31:11 +04:00
|
|
|
include('unstable/getopt.js');
|
|
|
|
[options, args] = getopt();
|
|
|
|
|
|
|
|
sys.include_path.push(options.topsrcdir);
|
|
|
|
|
2008-09-03 21:00:13 +04:00
|
|
|
include('string-format.js');
|
|
|
|
|
2008-06-06 23:31:11 +04:00
|
|
|
let modules = [];
|
|
|
|
|
|
|
|
function LoadModules(modulelist)
|
|
|
|
{
|
|
|
|
if (modulelist == "")
|
|
|
|
return;
|
|
|
|
|
|
|
|
let modulenames = modulelist.split(',');
|
|
|
|
for each (let modulename in modulenames) {
|
|
|
|
let module = { __proto__: this };
|
|
|
|
include(modulename, module);
|
|
|
|
modules.push(module);
|
|
|
|
}
|
2008-05-01 04:47:27 +04:00
|
|
|
}
|
|
|
|
|
2008-06-06 23:31:11 +04:00
|
|
|
LoadModules(options['dehydra-modules']);
|
|
|
|
if (treehydra_enabled())
|
|
|
|
LoadModules(options['treehydra-modules']);
|
|
|
|
|
2008-03-27 21:03:59 +03:00
|
|
|
function process_type(c)
|
2008-02-27 19:28:13 +03:00
|
|
|
{
|
2008-06-06 23:31:11 +04:00
|
|
|
for each (let module in modules)
|
|
|
|
if (module.hasOwnProperty('process_type'))
|
|
|
|
module.process_type(c);
|
2008-02-27 19:28:13 +03:00
|
|
|
}
|
|
|
|
|
2008-06-30 20:44:06 +04:00
|
|
|
function hasAttribute(c, attrname)
|
2008-02-27 19:28:13 +03:00
|
|
|
{
|
2008-06-30 20:44:06 +04:00
|
|
|
var attr;
|
2008-02-27 19:28:13 +03:00
|
|
|
|
2008-06-30 20:44:06 +04:00
|
|
|
if (c.attributes === undefined)
|
2008-02-27 19:28:13 +03:00
|
|
|
return false;
|
|
|
|
|
2008-06-30 20:44:06 +04:00
|
|
|
for each (attr in c.attributes)
|
|
|
|
if (attr.name == 'user' && attr.value[0] == attrname)
|
|
|
|
return true;
|
2008-02-27 19:28:13 +03:00
|
|
|
|
2008-06-30 20:44:06 +04:00
|
|
|
return false;
|
2008-02-27 19:28:13 +03:00
|
|
|
}
|
|
|
|
function process_function(f, stmts)
|
|
|
|
{
|
2008-06-06 23:31:11 +04:00
|
|
|
for each (let module in modules)
|
|
|
|
if (module.hasOwnProperty('process_function'))
|
|
|
|
module.process_function(f, stmts);
|
|
|
|
}
|
2008-02-27 19:28:13 +03:00
|
|
|
|
2008-06-06 23:31:11 +04:00
|
|
|
function process_tree(fndecl)
|
|
|
|
{
|
|
|
|
for each (let module in modules)
|
|
|
|
if (module.hasOwnProperty('process_tree'))
|
|
|
|
module.process_tree(fndecl);
|
|
|
|
}
|
2008-02-27 19:28:13 +03:00
|
|
|
|
2008-09-03 21:00:13 +04:00
|
|
|
function process_decl(decl)
|
2008-06-06 23:31:11 +04:00
|
|
|
{
|
|
|
|
for each (let module in modules)
|
2009-01-12 22:21:11 +03:00
|
|
|
if (module.hasOwnProperty('process_decl'))
|
2008-09-03 21:00:13 +04:00
|
|
|
module.process_decl(decl);
|
|
|
|
}
|
|
|
|
|
|
|
|
function process_cp_pre_genericize(fndecl)
|
|
|
|
{
|
|
|
|
for each (let module in modules)
|
|
|
|
if (module.hasOwnProperty('process_cp_pre_genericize'))
|
|
|
|
module.process_cp_pre_genericize(fndecl);
|
2008-06-06 23:31:11 +04:00
|
|
|
}
|
2008-02-27 19:28:13 +03:00
|
|
|
|
2008-06-06 23:31:11 +04:00
|
|
|
function input_end()
|
|
|
|
{
|
|
|
|
for each (let module in modules)
|
|
|
|
if (module.hasOwnProperty('input_end'))
|
|
|
|
module.input_end();
|
2008-02-27 19:28:13 +03:00
|
|
|
}
|