@@ -64,6 +64,45 @@ private class StandardDeallocationFunction extends DeallocationFunction {
64
64
override int getFreedArg ( ) { result = freedArg }
65
65
}
66
66
67
+ /**
68
+ * Holds if `f` is an deallocation function according to the
69
+ * extensible `deallocationFunctionModel` predicate.
70
+ */
71
+ private predicate isDeallocationFunctionFromModel (
72
+ Function f , string namespace , string type , string name
73
+ ) {
74
+ exists ( boolean subtypes | deallocationFunctionModel ( namespace , type , subtypes , name , _) |
75
+ if type = ""
76
+ then f .hasQualifiedName ( namespace , "" , name )
77
+ else
78
+ exists ( Class c |
79
+ c .hasQualifiedName ( namespace , type ) and f .hasQualifiedName ( namespace , _, name )
80
+ |
81
+ if subtypes = true
82
+ then f = c .getADerivedClass * ( ) .getAMemberFunction ( )
83
+ else f = c .getAMemberFunction ( )
84
+ )
85
+ )
86
+ }
87
+
88
+ /**
89
+ * A deallocation function modeled via the extensible `deallocationFunctionModel` predicate.
90
+ */
91
+ private class DeallocationFunctionFromModel extends DeallocationFunction {
92
+ string namespace ;
93
+ string type ;
94
+ string name ;
95
+
96
+ DeallocationFunctionFromModel ( ) { isDeallocationFunctionFromModel ( this , namespace , type , name ) }
97
+
98
+ final override int getFreedArg ( ) {
99
+ exists ( string freedArg |
100
+ deallocationFunctionModel ( namespace , type , _, name , freedArg ) and
101
+ result = freedArg .toInt ( )
102
+ )
103
+ }
104
+ }
105
+
67
106
/**
68
107
* An deallocation expression that is a function call, such as call to `free`.
69
108
*/
0 commit comments