| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3049bf2 commit d5cc42e
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -49,28 +49,45 @@ predicate side_effecting_descriptor_type(ClassObject descriptor) { | |||
| 49 | 49 | * side-effecting unless we know otherwise. | |
| 50 | 50 | */ | |
| 51 | 51 | predicate side_effecting_binary(Expr b) { | |
| 52 | - exists(Expr sub, string method_name | | ||
| 53 | - sub = b.(BinaryExpr).getLeft() and | ||
| 54 | - method_name = b.(BinaryExpr).getOp().getSpecialMethodName() | ||
| 52 | + exists(Expr sub, ClassObject cls, string method_name | | ||
| 53 | + binary_operator_special_method(b, sub, cls, method_name) | ||
| 55 | 54 | or | |
| 56 | - exists(Cmpop op | | ||
| 57 | - b.(Compare).compares(sub, op, _) and | ||
| 58 | - method_name = op.getSpecialMethodName() | ||
| 59 | - ) | ||
| 55 | + comparison_special_method(b, sub, cls, method_name) | ||
| 60 | 56 | | | |
| 61 | - exists(ClassObject cls | | ||
| 62 | - sub.refersTo(_, cls, _) and | ||
| 63 | - cls.hasAttribute(method_name) | ||
| 64 | - and | ||
| 65 | - not exists(ClassObject declaring | | ||
| 66 | - declaring.declaresAttribute(method_name) | ||
| 67 | - and declaring = cls.getAnImproperSuperType() and | ||
| 68 | - declaring.isBuiltin() and not declaring = theObjectType() | ||
| 69 | - ) | ||
| 57 | + method_name = special_method() and | ||
| 58 | + cls.hasAttribute(method_name) | ||
| 59 | + and | ||
| 60 | + not exists(ClassObject declaring | | ||
| 61 | + declaring.declaresAttribute(method_name) | ||
| 62 | + and declaring = cls.getAnImproperSuperType() and | ||
| 63 | + declaring.isBuiltin() and not declaring = theObjectType() | ||
| 70 | 64 | ) | |
| 71 | 65 | ) | |
| 72 | 66 | } | |
| 73 | 67 | ||
| 68 | + pragma[nomagic] | ||
| 69 | + private predicate binary_operator_special_method(BinaryExpr b, Expr sub, ClassObject cls, string method_name) { | ||
| 70 | + method_name = special_method() and | ||
| 71 | + sub = b.getLeft() and | ||
| 72 | + method_name = b.getOp().getSpecialMethodName() and | ||
| 73 | + sub.refersTo(_, cls, _) | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + pragma[nomagic] | ||
| 77 | + private predicate comparison_special_method(Compare b, Expr sub, ClassObject cls, string method_name) { | ||
| 78 | + exists(Cmpop op | | ||
| 79 | + b.compares(sub, op, _) and | ||
| 80 | + method_name = op.getSpecialMethodName() | ||
| 81 | + ) and | ||
| 82 | + sub.refersTo(_, cls, _) | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + private string special_method() { | ||
| 86 | + result = any(Cmpop c).getSpecialMethodName() | ||
| 87 | + or | ||
| 88 | + result = any(BinaryExpr b).getOp().getSpecialMethodName() | ||
| 89 | + } | ||
| 90 | + | ||
| 74 | 91 | predicate is_notebook(File f) { | |
| 75 | 92 | exists(Comment c | | |
| 76 | 93 | c.getLocation().getFile() = f | | |
| Back | FazBrowse Home | New Git URL |
0 commit comments