Python: factor out helper predicate to prevent bad join-order.

This commit is contained in:
Mark Shannon
2019-02-19 12:21:41 +00:00
parent 9dc624578e
commit 17681d6de4

View File

@@ -752,12 +752,6 @@ module PointsTo {
origin = orig.asCfgNodeOrHere(f)
|
mod.getSourceModule() = f.getEnclosingModule() and
exists(EssaVariable var |
var.getSourceVariable().getName() = name and var.getAUse() = f and
ssa_variable_points_to(var, context, value, cls, orig)
)
or
mod.getSourceModule() = f.getEnclosingModule() and
not exists(EssaVariable var | var.getSourceVariable().getName() = name and var.getAUse() = f) and
exists(EssaVariable dollar |
isModuleStateVariable(dollar) and dollar.getAUse() = f and
@@ -767,6 +761,20 @@ module PointsTo {
not mod.getSourceModule() = f.getEnclosingModule() and
Layer::module_attribute_points_to(mod, name, value, cls, orig)
)
or
exists(EssaVariable var, CfgOrigin orig |
var = ssa_variable_for_module_attribute(f, context) and
ssa_variable_points_to(var, context, value, cls, orig) and
origin = orig.asCfgNodeOrHere(f)
)
}
private EssaVariable ssa_variable_for_module_attribute(ImportMemberNode f, PointsToContext context) {
exists(string name, ModuleObject mod, Module m |
mod.getSourceModule() = m and m = f.getEnclosingModule() and m = result.getScope() and
points_to(f.getModule(name), context, mod, _, _) and
result.getSourceVariable().getName() = name and result.getAUse() = f
)
}
/** Holds if `f` is of the form `getattr(x, "name")` and x.name points to `(value, cls, origin)`. */