More performance stuff. (Possibly not all needed.)

This commit is contained in:
Taus Brock-Nannestad
2019-07-04 17:28:40 +02:00
parent 11ceaf3e3c
commit d2113f1ced
3 changed files with 22 additions and 7 deletions

View File

@@ -229,14 +229,18 @@ private predicate method_callsite_defn(MethodCallsiteRefinement def, Definition
pragma [noinline]
private predicate module_and_name_for_import_star(ModuleObject mod, string name, ImportStarRefinement def) {
exists(ImportStarNode im_star |
im_star = def.getDefiningNode() |
name = def.getSourceVariable().getName() and
im_star.getModule().refersTo(mod) and
module_and_name_for_import_star_helper(mod, name, im_star, def) and
mod.exports(name)
)
}
/** Holds if `def` is technically a defn of `var`, but the `from ... import *` does not in fact define `var` */
pragma [noinline]
private predicate module_and_name_for_import_star_helper(ModuleObject mod, string name, ImportStarNode im_star, ImportStarRefinement def) {
im_star = def.getDefiningNode() and
im_star.getModule().refersTo(mod) and
name = def.getSourceVariable().getName()
}
/** Holds if `def` is technically a defn of `var`, but the `from ... import *` does not in fact define `var` */
pragma [noinline]
private predicate variable_not_redefined_by_import_star(EssaVariable var, ImportStarRefinement def) {
var = def.getInput() and

View File

@@ -667,12 +667,18 @@ private module InterModulePointsTo {
pragma [noinline]
private EssaVariable ssa_variable_for_module_attribute(ImportMemberNode f, PointsToContext context) {
exists(string name, ModuleObjectInternal mod, Module m |
mod.getSourceModule() = m and m = f.getEnclosingModule() and m = result.getScope() and
mod.getSourceModule() = m and m = result.getScope() and
PointsToInternal::pointsTo(f.getModule(name), context, mod, _) and
result.getSourceVariable().getName() = name and result.getAUse() = f
result = ssa_helper(f, name, m)
)
}
pragma [noinline]
private EssaVariable ssa_helper(ImportMemberNode f, string name, Module m) {
result.getSourceVariable().getName() = name and result.getAUse() = f
and m = f.getEnclosingModule()
}
/* Helper for implicit_submodule_points_to */
private ModuleObjectInternal getModule(ImplicitSubModuleDefinition def) {
exists(PackageObjectInternal package |

View File

@@ -142,7 +142,12 @@ class ReModulePointToExtension extends PointsToExtension {
sre_constants.attribute("SRE_FLAG_" + name, value, orig) and
origin = orig.asCfgNodeOrHere(this)
)
and context.appliesTo(this)
and pointsTo_helper(context)
}
pragma [noinline]
predicate pointsTo_helper(Context context) {
context.appliesTo(this)
}
}