@@ -12,27 +12,38 @@ import semmle.code.cpp.Function
1212import semmle.code.cpp.models.Models
1313
1414/**
15- * An allocation function such as `malloc`.
15+ * An allocation expression such as call to `malloc` or a `new` expression .
1616 */
17- abstract class AllocationFunction extends Function {
17+ abstract class AllocationExpr extends Expr {
1818 /**
19- * Gets the index of the argument for the allocation size, if any. The actual
20- * allocation size is the value of this argument multiplied by the result of
19+ * Gets an expression for the allocation size, if any. The actual allocation
20+ * size is the value of this expression multiplied by the result of
2121 * `getSizeMult()`, in bytes.
2222 */
23- int getSizeArg ( ) { none ( ) }
23+ Expr getSizeExpr ( ) { none ( ) }
2424
2525 /**
26- * Gets the index of an argument that multiplies the allocation size given by
27- * `getSizeArg`, if any .
26+ * Gets a constant multiplier for the allocation size given by `getSizeExpr`,
27+ * in bytes .
2828 */
2929 int getSizeMult ( ) { none ( ) }
3030
3131 /**
32- * Gets the index of the input pointer argument to be reallocated, if this
33- * is a `realloc` function .
32+ * Gets the size of this allocation in bytes, if it is a fixed size and that
33+ * size can be determined .
3434 */
35- int getReallocPtrArg ( ) { none ( ) }
35+ int getSizeBytes ( ) { none ( ) }
36+
37+ /**
38+ * Gets the expression for the input pointer argument to be reallocated, if
39+ * this is a `realloc` function.
40+ */
41+ Expr getReallocPtr ( ) { none ( ) }
42+
43+ /**
44+ * Gets the type of the elements that are allocated, if it can be determined.
45+ */
46+ Type getAllocatedElementType ( ) { none ( ) }
3647
3748 /**
3849 * Whether or not this allocation requires a corresponding deallocation of
@@ -44,38 +55,30 @@ abstract class AllocationFunction extends Function {
4455}
4556
4657/**
47- * An allocation expression such as call to `malloc` or a `new` expression.
58+ * An allocation function such as `malloc`.
59+ *
60+ * Note: `AllocationExpr` includes calls to allocation functions, so prefer
61+ * to use that class unless you specifically need to reason about functions.
4862 */
49- abstract class AllocationExpr extends Expr {
63+ abstract class AllocationFunction extends Function {
5064 /**
51- * Gets an expression for the allocation size, if any. The actual allocation
52- * size is the value of this expression multiplied by the result of
65+ * Gets the index of the argument for the allocation size, if any. The actual
66+ * allocation size is the value of this argument multiplied by the result of
5367 * `getSizeMult()`, in bytes.
5468 */
55- Expr getSizeExpr ( ) { none ( ) }
69+ int getSizeArg ( ) { none ( ) }
5670
5771 /**
58- * Gets a constant multiplier for the allocation size given by `getSizeExpr`,
59- * in bytes .
72+ * Gets the index of an argument that multiplies the allocation size given by
73+ * `getSizeArg`, if any .
6074 */
6175 int getSizeMult ( ) { none ( ) }
6276
6377 /**
64- * Gets the size of this allocation in bytes, if it is a fixed size and that
65- * size can be determined.
66- */
67- int getSizeBytes ( ) { none ( ) }
68-
69- /**
70- * Gets the expression for the input pointer argument to be reallocated, if
71- * this is a `realloc` function.
72- */
73- Expr getReallocPtr ( ) { none ( ) }
74-
75- /**
76- * Gets the type of the elements that are allocated, if it can be determined.
78+ * Gets the index of the input pointer argument to be reallocated, if this
79+ * is a `realloc` function.
7780 */
78- Type getAllocatedElementType ( ) { none ( ) }
81+ int getReallocPtrArg ( ) { none ( ) }
7982
8083 /**
8184 * Whether or not this allocation requires a corresponding deallocation of
0 commit comments