@@ -80,6 +80,8 @@ newtype TObject =
8080 TSpecificInstance ( ControlFlowNode instantiation , ClassObjectInternal cls , PointsToContext context ) {
8181 PointsTo2:: points_to ( instantiation .( CallNode ) .getFunction ( ) , context , cls , _) and
8282 cls .isSpecial ( ) = false
83+ or
84+ literal_instantiation ( instantiation , cls , context )
8385 }
8486 or
8587 TSelfInstance ( ParameterDefinition def , PointsToContext context , PythonClassObjectInternal cls ) {
@@ -129,6 +131,19 @@ predicate class_method(CallNode instantiation, CallableObjectInternal function,
129131 PointsTo2:: points_to ( instantiation .getArg ( 0 ) , context , function , _)
130132}
131133
134+ predicate literal_instantiation ( ControlFlowNode n , ClassObjectInternal cls , PointsToContext context ) {
135+ context .appliesTo ( n ) and
136+ (
137+ n instanceof ListNode and cls = ObjectInternal:: builtin ( "list" )
138+ or
139+ n instanceof DictNode and cls = ObjectInternal:: builtin ( "dict" )
140+ or
141+ n .getNode ( ) instanceof FloatLiteral and cls = ObjectInternal:: builtin ( "float" )
142+ or
143+ n .getNode ( ) instanceof ImaginaryLiteral and cls = ObjectInternal:: builtin ( "complex" )
144+ )
145+ }
146+
132147predicate super_instantiation ( CallNode instantiation , ObjectInternal self , ClassObjectInternal startclass , PointsToContext context ) {
133148 PointsTo2:: points_to ( instantiation .getFunction ( ) , context , ObjectInternal:: builtin ( "super" ) , _) and
134149 (
@@ -267,12 +282,20 @@ library class ClassDecl extends @py_object {
267282 predicate isSpecial ( ) {
268283 exists ( string name |
269284 this = Builtin:: special ( name ) |
270- not name = "object" and
271- not name = "list" and
272- not name = "set" and
273- not name = "dict" and
274- not name .matches ( "%Exception" ) and
275- not name .matches ( "%Error" )
285+ name = "type" or
286+ name = "bool" or
287+ name = "NoneType" or
288+ name = "int" or
289+ name = "long" or
290+ name = "str" or
291+ name = "bytes" or
292+ name = "unicode" or
293+ name = "tuple" or
294+ name = "property" or
295+ name = "classmethod" or
296+ name = "staticmethod" or
297+ name = "MethodType" or
298+ name = "ModuleType"
276299 )
277300 }
278301
0 commit comments