зеркало из https://github.com/mozilla/pjs.git
Bug 437647 - Dispatch outparams and other analyses explicitly, so it's easier to add various analyses, r=dmandelin
This commit is contained in:
Родитель
0429dc9698
Коммит
5a71b4b11e
|
@ -62,6 +62,8 @@ include $(topsrcdir)/config/insure.mk
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
COMMA = ,
|
||||||
|
|
||||||
# Sanity check some variables
|
# Sanity check some variables
|
||||||
CHECK_VARS := \
|
CHECK_VARS := \
|
||||||
XPI_NAME \
|
XPI_NAME \
|
||||||
|
@ -522,10 +524,26 @@ endif
|
||||||
# The entire tree should be subject to static analysis using the XPCOM
|
# The entire tree should be subject to static analysis using the XPCOM
|
||||||
# script. Additional scripts may be added by specific subdirectories.
|
# script. Additional scripts may be added by specific subdirectories.
|
||||||
|
|
||||||
DEHYDRA_SCRIPTS = $(topsrcdir)/xpcom/analysis/static-checking.js
|
DEHYDRA_SCRIPT = $(topsrcdir)/xpcom/analysis/static-checking.js
|
||||||
|
|
||||||
|
DEHYDRA_MODULES = \
|
||||||
|
$(topsrcdir)/xpcom/analysis/stack.js \
|
||||||
|
$(NULL)
|
||||||
|
|
||||||
|
TREEHYDRA_MODULES = \
|
||||||
|
$(topsrcdir)/xpcom/analysis/outparams.js \
|
||||||
|
$(NULL)
|
||||||
|
|
||||||
|
DEHYDRA_ARGS = \
|
||||||
|
--topsrcdir=$(topsrcdir) \
|
||||||
|
--objdir=$(DEPTH) \
|
||||||
|
--dehydra-modules=$(subst $(NULL) ,$(COMMA),$(strip $(DEHYDRA_MODULES))) \
|
||||||
|
--treehydra-modules=$(subst $(NULL) ,$(COMMA),$(strip $(TREEHYDRA_MODULES))) \
|
||||||
|
$(NULL)
|
||||||
|
|
||||||
|
DEHYDRA_FLAGS = -fplugin=$(DEHYDRA_PATH) -fplugin-arg="$(DEHYDRA_SCRIPT) $(DEHYDRA_ARGS)"
|
||||||
|
|
||||||
ifdef DEHYDRA_PATH
|
ifdef DEHYDRA_PATH
|
||||||
DEHYDRA_FLAGS = -fplugin=$(DEHYDRA_PATH) $(foreach script,$(DEHYDRA_SCRIPTS),-fplugin-arg=$(script))
|
|
||||||
OS_CXXFLAGS += $(DEHYDRA_FLAGS)
|
OS_CXXFLAGS += $(DEHYDRA_FLAGS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
function process_function(f, stmts)
|
||||||
|
{
|
||||||
|
var stmt;
|
||||||
|
function getLocation()
|
||||||
|
{
|
||||||
|
if (stmt.loc)
|
||||||
|
return stmt.loc;
|
||||||
|
|
||||||
|
return f.loc;
|
||||||
|
}
|
||||||
|
|
||||||
|
function processVar(v)
|
||||||
|
{
|
||||||
|
if (v.isConstructor &&
|
||||||
|
v.fieldOf &&
|
||||||
|
get_class(v.memberOf, false).stack &&
|
||||||
|
v.fieldOf.type.isPointer) {
|
||||||
|
error(getLocation() + ": constructed object of type '" +
|
||||||
|
v.memberOf.name + "' not on the stack.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for each (stmt in stmts) {
|
||||||
|
iter(processVar, stmt.statements);
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,10 +10,32 @@ function treehydra_enabled() {
|
||||||
return this.hasOwnProperty('TREE_CODE');
|
return this.hasOwnProperty('TREE_CODE');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (treehydra_enabled()) {
|
include('unstable/getopt.js');
|
||||||
include('outparams.js');
|
[options, args] = getopt();
|
||||||
|
|
||||||
|
// XXXbugfix: when you pass arguments to -fplugin-arg, include_path[0] is bad
|
||||||
|
sys.include_path[0] = options.topsrcdir + "/xpcom/analysis";
|
||||||
|
sys.include_path.push(options.topsrcdir);
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LoadModules(options['dehydra-modules']);
|
||||||
|
if (treehydra_enabled())
|
||||||
|
LoadModules(options['treehydra-modules']);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gClassMap maps class names to an object with the following properties:
|
* gClassMap maps class names to an object with the following properties:
|
||||||
*
|
*
|
||||||
|
@ -38,6 +60,10 @@ function process_type(c)
|
||||||
{
|
{
|
||||||
if (c.kind == 'class' || c.kind == 'struct')
|
if (c.kind == 'class' || c.kind == 'struct')
|
||||||
get_class(c, true);
|
get_class(c, true);
|
||||||
|
|
||||||
|
for each (let module in modules)
|
||||||
|
if (module.hasOwnProperty('process_type'))
|
||||||
|
module.process_type(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -200,27 +226,28 @@ function unwrapArray(t)
|
||||||
|
|
||||||
function process_function(f, stmts)
|
function process_function(f, stmts)
|
||||||
{
|
{
|
||||||
var stmt;
|
for each (let module in modules)
|
||||||
function getLocation()
|
if (module.hasOwnProperty('process_function'))
|
||||||
{
|
module.process_function(f, stmts);
|
||||||
if (stmt.loc)
|
}
|
||||||
return stmt.loc;
|
|
||||||
|
function process_tree(fndecl)
|
||||||
return f.loc;
|
{
|
||||||
}
|
for each (let module in modules)
|
||||||
|
if (module.hasOwnProperty('process_tree'))
|
||||||
function processVar(v)
|
module.process_tree(fndecl);
|
||||||
{
|
}
|
||||||
if (v.isConstructor &&
|
|
||||||
v.fieldOf &&
|
function process_var(decl)
|
||||||
get_class(v.methodOf, false).stack &&
|
{
|
||||||
v.fieldOf.type.isPointer) {
|
for each (let module in modules)
|
||||||
error(getLocation() + ": constructed object of type '" +
|
if (module.hasOwnProperty('process_var'))
|
||||||
v.methodOf.name + "' not on the stack.");
|
module.process_var(decl);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
function input_end()
|
||||||
for each (stmt in stmts) {
|
{
|
||||||
iter(processVar, stmt.statements);
|
for each (let module in modules)
|
||||||
}
|
if (module.hasOwnProperty('input_end'))
|
||||||
|
module.input_end();
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче