File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55import cpp
66import semmle.code.cpp.controlflow.SSA
77import semmle.code.cpp.dataflow.DataFlow
8- import semmle.code.cpp.models.implementations.Allocation
9- import semmle.code.cpp.models.implementations.Deallocation
108
119/**
1210 * Holds if `alloc` is a use of `malloc` or `new`. `kind` is
Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ import semmle.code.cpp.Element
66private import semmle.code.cpp.Enclosing
77private import semmle.code.cpp.internal.ResolveClass
88private import semmle.code.cpp.internal.AddressConstantExpression
9- private import semmle.code.cpp.models.implementations.Allocation
109
1110/**
1211 * A C/C++ expression.
Original file line number Diff line number Diff line change @@ -237,12 +237,10 @@ private class SizelessAllocationFunction extends AllocationFunction {
237237}
238238
239239/**
240- * An `operator new` or `operator new[]` function that may be associated with `new` or
241- * `new[]` expressions. Note that `new` and `new[]` are not function calls, but these
242- * functions may also be called directly.
240+ * Implements `OperatorNewAllocationFunction`.
243241 */
244- class OperatorNewAllocationFunction extends AllocationFunction {
245- OperatorNewAllocationFunction ( ) {
242+ private class OperatorNewAllocationFunctionImpl extends OperatorNewAllocationFunction {
243+ OperatorNewAllocationFunctionImpl ( ) {
246244 exists ( string name |
247245 hasGlobalName ( name ) and
248246 (
@@ -259,11 +257,7 @@ class OperatorNewAllocationFunction extends AllocationFunction {
259257
260258 override predicate requiresDealloc ( ) { not exists ( getPlacementArgument ( ) ) }
261259
262- /**
263- * Gets the position of the placement pointer if this is a placement
264- * `operator new` function.
265- */
266- int getPlacementArgument ( ) {
260+ override int getPlacementArgument ( ) {
267261 getNumberOfParameters ( ) = 2 and
268262 getParameter ( 1 ) .getType ( ) instanceof VoidPointerType and
269263 result = 1
Original file line number Diff line number Diff line change @@ -90,12 +90,10 @@ private class StandardDeallocationFunction extends DeallocationFunction {
9090}
9191
9292/**
93- * An `operator delete` or `operator delete[]` function that may be associated
94- * with `delete` or `delete[]` expressions. Note that `delete` and `delete[]`
95- * are not function calls, but these functions may also be called directly.
93+ * Implements `OperatorDeleteDeallocationFunction`.
9694 */
97- class OperatorDeleteDeallocationFunction extends DeallocationFunction {
98- OperatorDeleteDeallocationFunction ( ) {
95+ private class OperatorDeleteDeallocationFunctionImpl extends OperatorDeleteDeallocationFunction {
96+ OperatorDeleteDeallocationFunctionImpl ( ) {
9997 exists ( string name |
10098 hasGlobalName ( name ) and
10199 (
Original file line number Diff line number Diff line change @@ -85,3 +85,16 @@ abstract class AllocationExpr extends Expr {
8585 */
8686 predicate requiresDealloc ( ) { any ( ) }
8787}
88+
89+ /**
90+ * An `operator new` or `operator new[]` function that may be associated with
91+ * `new` or `new[]` expressions. Note that `new` and `new[]` are not function
92+ * calls, but these functions may also be called directly.
93+ */
94+ abstract class OperatorNewAllocationFunction extends AllocationFunction {
95+ /**
96+ * Gets the position of the placement pointer if this is a placement
97+ * `operator new` function.
98+ */
99+ int getPlacementArgument ( ) { none ( ) }
100+ }
Original file line number Diff line number Diff line change @@ -30,3 +30,11 @@ abstract class DeallocationExpr extends Expr {
3030 */
3131 Expr getFreedExpr ( ) { none ( ) }
3232}
33+
34+ /**
35+ * An `operator delete` or `operator delete[]` function that may be associated
36+ * with `delete` or `delete[]` expressions. Note that `delete` and `delete[]`
37+ * are not function calls, but these functions may also be called directly.
38+ */
39+ abstract class OperatorDeleteDeallocationFunction extends DeallocationFunction {
40+ }
You can’t perform that action at this time.
0 commit comments