@@ -30,42 +30,31 @@ class PlacementNewOrNewArrayAllocationFunction extends AllocationFunction {
3030}
3131
3232class DynamicMemoryManagementFunction extends Function {
33- string description ;
34-
3533 DynamicMemoryManagementFunction ( ) {
36- (
37- ( this instanceof AllocationFunction or this instanceof AlignedAllocFunction ) and
38- /* Avoid duplicate alerts on `realloc` which is both an `AllocationFunction` and a `DeallocationFunction`. */
39- not this instanceof ReallocFunction and
40- /* Placement-new expressions are not prohibited by this rule, but by Rule 21.6.3. */
41- not this instanceof PlacementNewOrNewArrayAllocationFunction
42- ) and
43- description = "an expression that dynamically allocates memory"
34+ ( this instanceof AllocationFunction or this instanceof AlignedAllocFunction ) and
35+ /* Avoid duplicate alerts on `realloc` which is both an `AllocationFunction` and a `DeallocationFunction`. */
36+ not this instanceof ReallocFunction and
37+ /* Placement-new expressions are not prohibited by this rule, but by Rule 21.6.3. */
38+ not this instanceof PlacementNewOrNewArrayAllocationFunction
4439 or
4540 this instanceof DeallocationFunction and
4641 /* Avoid duplicate alerts on `realloc` which is both an `AllocationFunction` and a `DeallocationFunction`. */
47- not this instanceof ReallocFunction and
48- description = "an expression that dynamically deallocates memory"
42+ not this instanceof ReallocFunction
4943 or
50- this instanceof ReallocFunction and
51- description = "an expression that dynamically reallocates memory"
44+ this instanceof ReallocFunction
5245 or
53- this instanceof AllocateOrDeallocateStdlibMemberFunction and
54- description = "a standard library function that manages memory manually"
46+ this instanceof AllocateOrDeallocateStdlibMemberFunction
5547 or
56- this instanceof UniquePointerReleaseFunction and
57- description = "`std::unique_ptr::release`"
48+ this instanceof UniquePointerReleaseFunction
5849 }
59-
60- string describe ( ) { result = description }
6150}
6251
6352/**
6453 * A function that has namespace `std` and has name `allocate` or `deallocate`, including but not limited to:
6554 * - `std::allocator<T>::allocate(std::size_t)`
6655 * - `std::allocator<T>::dellocate(T*, std::size_t)`
6756 * - `std::pmr::memory_resource::allocate(std::size_t, std::size_t)`
68- * - `std::pmr::memory_resource::allocate( std::size_t, std::size_t)`
57+ * - `std::pmr::memory_resource::deallocate(void*, std::size_t, std::size_t)`
6958 */
7059class AllocateOrDeallocateStdlibMemberFunction extends MemberFunction {
7160 AllocateOrDeallocateStdlibMemberFunction ( ) {
@@ -101,14 +90,12 @@ where
10190 exists ( DynamicMemoryManagementFunction dynamicMemoryManagementFunction |
10291 /* ===== 1. The expression calls one of the dynamic memory management functions. ===== */
10392 expr = dynamicMemoryManagementFunction .getACallToThisFunction ( ) and
104- message =
105- "Banned call to `" + dynamicMemoryManagementFunction .getName ( ) + "` which is " +
106- dynamicMemoryManagementFunction .describe ( ) + "."
93+ message = "Banned call to `" + dynamicMemoryManagementFunction .getQualifiedName ( ) + "`."
10794 or
10895 /* ===== 2. The expression takes address of the dynamic memory management functions. ===== */
10996 expr = dynamicMemoryManagementFunction .getAnAccess ( ) and
11097 message =
111- "Taking the address of a banned function `" + dynamicMemoryManagementFunction . getName ( ) +
112- "` which is " + dynamicMemoryManagementFunction .describe ( ) + "."
98+ "Taking the address of a banned function `" +
99+ dynamicMemoryManagementFunction .getQualifiedName ( ) + "` ."
113100 )
114101select expr , message
0 commit comments