Python: Remove Value.getSource(). It has no use.

This commit is contained in:
Mark Shannon
2019-06-13 14:28:57 +01:00
parent 8a43fdc806
commit 30e1cbc5fc
13 changed files with 24 additions and 27 deletions

View File

@@ -67,9 +67,9 @@ class Module extends Module_, Scope, AstNode {
string getAnExport() {
py_exports(this, result)
or
exists(ModuleValue mod |
exists(ModuleObjectInternal mod |
mod.getSource() = this.getEntryNode() |
mod.exports(result)
mod.(ModuleValue).exports(result)
)
}

View File

@@ -71,13 +71,6 @@ class Value extends TObject {
this.(ObjectInternal).attribute(name, result, _)
}
/** DEPRECATED: For backwards compatibility with old API
* Use `Value` instead of `ObjectSource`.
*/
deprecated ObjectSource getSource() {
result = this.(ObjectInternal).getSource()
}
/** Holds if this value is builtin. Applies to built-in functions and methods,
* but also integers and strings.
*/

View File

@@ -141,7 +141,7 @@ module PointsTo {
)
or
not f.isParameter() and
exists(Value value |
exists(ObjectInternal value |
PointsToInternal::pointsTo(f.(DefinitionNode).getValue(), context, value, origin) and
cls = value.getClass().getSource() |
obj = value.getSource() or
@@ -151,7 +151,7 @@ module PointsTo {
deprecated predicate
ssa_variable_points_to(EssaVariable var, PointsToContext context, Object obj, ClassObject cls, CfgOrigin origin) {
exists(Value value |
exists(ObjectInternal value |
PointsToInternal::variablePointsTo(var, context, value, origin) and
cls = value.getClass().getSource() |
obj = value.getSource()
@@ -160,8 +160,8 @@ module PointsTo {
deprecated
CallNode get_a_call(Object func, PointsToContext context) {
exists(Value value |
result = value.getACall(context) and
exists(ObjectInternal value |
result = value.(Value).getACall(context) and
func = value.getSource()
)
}

View File

@@ -144,7 +144,7 @@ abstract class TaintKind extends string {
* the `result` would be `theStrType()`.
*/
ClassValue getType() {
result.getSource() = this.getClass()
result.(ClassObjectInternal).getSource() = this.getClass()
}
/** Gets the boolean values (may be one, neither, or both) that

View File

@@ -4,6 +4,7 @@ private import semmle.python.objects.Instances
private import semmle.python.pointsto.PointsTo
private import semmle.python.pointsto.MRO
private import semmle.python.types.Builtins
private import semmle.python.objects.ObjectInternal
/** A class whose instances represents Python classes.
@@ -99,7 +100,7 @@ class ClassObject extends Object {
/** Returns an attribute declared on this class (not on a super-class) */
Object declaredAttribute(string name) {
exists(Value val |
exists(ObjectInternal val |
Types::declaredAttribute(theClass(), name, val, _) and
result = val.getSource()
)
@@ -113,7 +114,7 @@ class ClassObject extends Object {
/** Returns an attribute as it would be when looked up at runtime on this class.
Will include attributes of super-classes */
Object lookupAttribute(string name) {
exists(Value val |
exists(ObjectInternal val |
theClass().lookup(name, val, _) and
result = val.getSource()
)
@@ -125,7 +126,7 @@ class ClassObject extends Object {
/** Looks up an attribute by searching this class' MRO starting at `start` */
Object lookupMro(ClassObject start, string name) {
exists(ClassObjectInternal other, ClassObjectInternal decl, Value val |
exists(ClassObjectInternal other, ClassObjectInternal decl, ObjectInternal val |
other.getSource() = start and
decl = Types::getMro(theClass()).startingAt(other).findDeclaringClass(name) and
Types::declaredAttribute(decl, name, val, _) and
@@ -140,7 +141,7 @@ class ClassObject extends Object {
/** Whether the named attribute refers to the object, class and origin */
predicate attributeRefersTo(string name, Object obj, ClassObject cls, ControlFlowNode origin) {
exists(Value val, CfgOrigin valorig |
exists(ObjectInternal val, CfgOrigin valorig |
theClass().lookup(name, val, valorig) and
obj = val.getSource() and
cls = val.getClass().getSource() and

View File

@@ -4,13 +4,14 @@ private import semmle.python.pointsto.PointsTo
private import semmle.python.objects.Callables
private import semmle.python.libraries.Zope
private import semmle.python.pointsto.Base
private import semmle.python.objects.ObjectInternal
private import semmle.python.types.Builtins
/** A function object, whether written in Python or builtin */
abstract class FunctionObject extends Object {
CallableValue theCallable() {
result.getSource() = this
result.(ObjectInternal).getSource() = this
}
predicate isOverridingMethod() {

View File

@@ -1,6 +1,6 @@
import python
private import semmle.python.pointsto.PointsTo
private import semmle.python.objects.Modules
private import semmle.python.objects.ObjectInternal
private import semmle.python.types.ModuleKind
abstract class ModuleObject extends Object {
@@ -54,7 +54,7 @@ abstract class ModuleObject extends Object {
}
predicate attributeRefersTo(string name, Object obj, ControlFlowNode origin) {
exists(Value val, CfgOrigin valorig |
exists(ObjectInternal val, CfgOrigin valorig |
theModule().(ModuleObjectInternal).attribute(name, val, valorig) and
obj = val.getSource() and
origin = valorig.toCfgNode()
@@ -62,7 +62,7 @@ abstract class ModuleObject extends Object {
}
predicate attributeRefersTo(string name, Object obj, ClassObject cls, ControlFlowNode origin) {
exists(Value val, CfgOrigin valorig |
exists(ObjectInternal val, CfgOrigin valorig |
theModule().(ModuleObjectInternal).attribute(name, val, valorig) and
obj = val.getSource() and
cls = val.getClass().getSource() and
@@ -223,7 +223,7 @@ class PackageObject extends ModuleObject {
}
override Object getAttribute(string name) {
exists(Value val |
exists(ObjectInternal val |
theModule().(PackageObjectInternal).attribute(name, val, _) and
result = val.getSource()
)