Skip to content

Commit f6f6f96

Browse files
committed
Decrease verbosity of alerts from both queries
1 parent e20878d commit f6f6f96

File tree

4 files changed

+131
-127
lines changed

4 files changed

+131
-127
lines changed

cpp/misra/src/rules/RULE-21-6-2/DynamicMemoryManagedManually.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ where
9595
/* ===== 2. The expression takes address of the dynamic memory management functions. ===== */
9696
expr = dynamicMemoryManagementFunction.getAnAccess() and
9797
message =
98-
"Taking the address of a banned function `" +
98+
"Taking the address of banned `" +
9999
dynamicMemoryManagementFunction.getQualifiedName() + "`."
100100
)
101101
select expr, message

cpp/misra/src/rules/RULE-21-6-3/AdvancedMemoryManagementUsed.ql

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ class AdvancedMemoryManagementFunction extends Function {
2323

2424
AdvancedMemoryManagementFunction() {
2525
this instanceof NonStandardNewOrNewArrayOperator and
26-
description = "a non-replaceable allocation function as operator `new` / `new[]`"
26+
description = "a non-replaceable allocation function"
2727
or
2828
this instanceof NonStandardDeleteOrDeleteArrayOperator and
29-
description = "a non-replaceable deallocation function as operator `delete` / `delete[]`"
29+
description = "a non-replaceable deallocation function"
3030
or
3131
this instanceof UninitializedMemoryManagementFunction and
3232
description = "a function from <memory> that manages uninitialized memory"
@@ -76,22 +76,26 @@ where
7676
/* 1. The element is a call to one of the advanced management functions. */
7777
element = advancedMemoryManagementFunction.getACallToThisFunction() and
7878
message =
79-
"Call to banned function `" + advancedMemoryManagementFunction.getName() + "` which is " +
80-
advancedMemoryManagementFunction.describe() + "."
79+
"Call to banned function `" + advancedMemoryManagementFunction.getName() +
80+
//"."
81+
"` which is " + advancedMemoryManagementFunction.describe() + "."
8182
or
8283
/* 2. The element takes address of the advanced memory management functions. */
8384
element = advancedMemoryManagementFunction.getAnAccess() and
8485
message =
85-
"This expression takes address of a banned function `" + advancedMemoryManagementFunction.getName() +
86+
"Taking the address of a banned function `" + advancedMemoryManagementFunction.getName() +
8687
"` which is " + advancedMemoryManagementFunction.describe() + "."
88+
// "`."
8789
)
8890
or
8991
(
9092
element instanceof VacuousDestructorCall or
9193
element instanceof ExplicitDestructorCall
9294
) and
93-
message = "This expression is a manual call to a destructor."
95+
message = "Manual call to a destructor."
9496
or
9597
element instanceof UserDeclaredOperatorNewOrDelete and
96-
message = "This is a user-provided declaration of `new` / `new[]` / `delete` / `delete[]`."
98+
message =
99+
"User-provided declaration of `" +
100+
element.(UserDeclaredOperatorNewOrDelete).getFunction().getName() + "`."
97101
select element, message

cpp/misra/test/rules/RULE-21-6-2/DynamicMemoryManagedManually.expected

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -36,49 +36,49 @@
3636
| test.cpp:151:10:151:16 | call to release | Banned call to `std::unique_ptr<C1[], default_delete<C1[]>>::release`. |
3737
| test.cpp:152:3:152:15 | call to operator delete[] | Banned call to `operator delete[]`. |
3838
| test.cpp:158:3:158:12 | call to operator delete | Banned call to `operator delete`. |
39-
| test.cpp:165:7:165:17 | malloc | Taking the address of a banned function `malloc`. |
40-
| test.cpp:167:8:167:18 | malloc | Taking the address of a banned function `malloc`. |
41-
| test.cpp:169:7:169:14 | malloc | Taking the address of a banned function `malloc`. |
42-
| test.cpp:171:8:171:15 | malloc | Taking the address of a banned function `malloc`. |
43-
| test.cpp:174:7:174:17 | calloc | Taking the address of a banned function `calloc`. |
44-
| test.cpp:176:8:176:18 | calloc | Taking the address of a banned function `calloc`. |
45-
| test.cpp:179:7:179:18 | realloc | Taking the address of a banned function `realloc`. |
46-
| test.cpp:181:8:181:19 | realloc | Taking the address of a banned function `realloc`. |
47-
| test.cpp:184:7:184:24 | aligned_alloc | Taking the address of a banned function `aligned_alloc`. |
48-
| test.cpp:186:8:186:25 | aligned_alloc | Taking the address of a banned function `aligned_alloc`. |
49-
| test.cpp:189:7:189:15 | free | Taking the address of a banned function `free`. |
50-
| test.cpp:191:8:191:16 | free | Taking the address of a banned function `free`. |
51-
| test.cpp:193:7:193:12 | free | Taking the address of a banned function `free`. |
52-
| test.cpp:195:8:195:13 | free | Taking the address of a banned function `free`. |
53-
| test.cpp:202:7:202:21 | operator new | Taking the address of a banned function `operator new`. |
54-
| test.cpp:204:7:204:20 | operator new | Taking the address of a banned function `operator new`. |
55-
| test.cpp:206:7:206:23 | operator new[] | Taking the address of a banned function `operator new[]`. |
56-
| test.cpp:208:7:208:22 | operator new[] | Taking the address of a banned function `operator new[]`. |
57-
| test.cpp:211:7:211:21 | operator new | Taking the address of a banned function `operator new`. |
58-
| test.cpp:213:7:213:23 | operator new[] | Taking the address of a banned function `operator new[]`. |
59-
| test.cpp:218:7:218:24 | operator delete | Taking the address of a banned function `operator delete`. |
60-
| test.cpp:220:7:220:23 | operator delete | Taking the address of a banned function `operator delete`. |
61-
| test.cpp:222:7:222:26 | operator delete[] | Taking the address of a banned function `operator delete[]`. |
62-
| test.cpp:223:24:223:42 | operator delete[] | Taking the address of a banned function `operator delete[]`. |
63-
| test.cpp:227:7:227:24 | operator delete | Taking the address of a banned function `operator delete`. |
64-
| test.cpp:229:7:229:26 | operator delete[] | Taking the address of a banned function `operator delete[]`. |
65-
| test.cpp:233:7:233:24 | operator delete | Taking the address of a banned function `operator delete`. |
66-
| test.cpp:235:7:235:26 | operator delete[] | Taking the address of a banned function `operator delete[]`. |
67-
| test.cpp:243:13:243:41 | allocate | Taking the address of a banned function `std::allocator<C1>::allocate`. |
68-
| test.cpp:245:13:245:43 | deallocate | Taking the address of a banned function `std::allocator<C1>::deallocate`. |
69-
| test.cpp:251:7:251:23 | allocate | Taking the address of a banned function `std::allocator_traits<allocator<C1>>::allocate`. |
70-
| test.cpp:254:8:254:25 | deallocate | Taking the address of a banned function `std::allocator_traits<allocator<C1>>::deallocate`. |
71-
| test.cpp:258:13:258:48 | allocate | Taking the address of a banned function `std::pmr::memory_resource::allocate`. |
72-
| test.cpp:261:7:261:44 | deallocate | Taking the address of a banned function `std::pmr::memory_resource::deallocate`. |
73-
| test.cpp:265:13:266:19 | allocate | Taking the address of a banned function `std::pmr::polymorphic_allocator<C1>::allocate`. |
74-
| test.cpp:268:13:269:21 | deallocate | Taking the address of a banned function `std::pmr::polymorphic_allocator<C1>::deallocate`. |
75-
| test.cpp:273:13:274:24 | allocate | Taking the address of a banned function `std::pmr::memory_resource::allocate`. |
76-
| test.cpp:276:14:277:27 | deallocate | Taking the address of a banned function `std::pmr::memory_resource::deallocate`. |
77-
| test.cpp:281:14:282:25 | allocate | Taking the address of a banned function `std::pmr::memory_resource::allocate`. |
78-
| test.cpp:284:14:285:27 | deallocate | Taking the address of a banned function `std::pmr::memory_resource::deallocate`. |
79-
| test.cpp:289:14:290:25 | allocate | Taking the address of a banned function `std::pmr::memory_resource::allocate`. |
80-
| test.cpp:292:14:293:27 | deallocate | Taking the address of a banned function `std::pmr::memory_resource::deallocate`. |
81-
| test.cpp:299:7:299:28 | allocate | Taking the address of a banned function `std::scoped_allocator_adaptor<allocator<C1>>::allocate`. |
82-
| test.cpp:302:7:302:30 | deallocate | Taking the address of a banned function `std::scoped_allocator_adaptor<allocator<C1>>::deallocate`. |
83-
| test.cpp:309:13:309:41 | release | Taking the address of a banned function `std::unique_ptr<C1, default_delete<C1>>::release`. |
84-
| test.cpp:312:7:312:37 | release | Taking the address of a banned function `std::unique_ptr<C1[], default_delete<C1[]>>::release`. |
39+
| test.cpp:165:7:165:17 | malloc | Taking the address of banned `malloc`. |
40+
| test.cpp:167:8:167:18 | malloc | Taking the address of banned `malloc`. |
41+
| test.cpp:169:7:169:14 | malloc | Taking the address of banned `malloc`. |
42+
| test.cpp:171:8:171:15 | malloc | Taking the address of banned `malloc`. |
43+
| test.cpp:174:7:174:17 | calloc | Taking the address of banned `calloc`. |
44+
| test.cpp:176:8:176:18 | calloc | Taking the address of banned `calloc`. |
45+
| test.cpp:179:7:179:18 | realloc | Taking the address of banned `realloc`. |
46+
| test.cpp:181:8:181:19 | realloc | Taking the address of banned `realloc`. |
47+
| test.cpp:184:7:184:24 | aligned_alloc | Taking the address of banned `aligned_alloc`. |
48+
| test.cpp:186:8:186:25 | aligned_alloc | Taking the address of banned `aligned_alloc`. |
49+
| test.cpp:189:7:189:15 | free | Taking the address of banned `free`. |
50+
| test.cpp:191:8:191:16 | free | Taking the address of banned `free`. |
51+
| test.cpp:193:7:193:12 | free | Taking the address of banned `free`. |
52+
| test.cpp:195:8:195:13 | free | Taking the address of banned `free`. |
53+
| test.cpp:202:7:202:21 | operator new | Taking the address of banned `operator new`. |
54+
| test.cpp:204:7:204:20 | operator new | Taking the address of banned `operator new`. |
55+
| test.cpp:206:7:206:23 | operator new[] | Taking the address of banned `operator new[]`. |
56+
| test.cpp:208:7:208:22 | operator new[] | Taking the address of banned `operator new[]`. |
57+
| test.cpp:211:7:211:21 | operator new | Taking the address of banned `operator new`. |
58+
| test.cpp:213:7:213:23 | operator new[] | Taking the address of banned `operator new[]`. |
59+
| test.cpp:218:7:218:24 | operator delete | Taking the address of banned `operator delete`. |
60+
| test.cpp:220:7:220:23 | operator delete | Taking the address of banned `operator delete`. |
61+
| test.cpp:222:7:222:26 | operator delete[] | Taking the address of banned `operator delete[]`. |
62+
| test.cpp:223:24:223:42 | operator delete[] | Taking the address of banned `operator delete[]`. |
63+
| test.cpp:227:7:227:24 | operator delete | Taking the address of banned `operator delete`. |
64+
| test.cpp:229:7:229:26 | operator delete[] | Taking the address of banned `operator delete[]`. |
65+
| test.cpp:233:7:233:24 | operator delete | Taking the address of banned `operator delete`. |
66+
| test.cpp:235:7:235:26 | operator delete[] | Taking the address of banned `operator delete[]`. |
67+
| test.cpp:243:13:243:41 | allocate | Taking the address of banned `std::allocator<C1>::allocate`. |
68+
| test.cpp:245:13:245:43 | deallocate | Taking the address of banned `std::allocator<C1>::deallocate`. |
69+
| test.cpp:251:7:251:23 | allocate | Taking the address of banned `std::allocator_traits<allocator<C1>>::allocate`. |
70+
| test.cpp:254:8:254:25 | deallocate | Taking the address of banned `std::allocator_traits<allocator<C1>>::deallocate`. |
71+
| test.cpp:258:13:258:48 | allocate | Taking the address of banned `std::pmr::memory_resource::allocate`. |
72+
| test.cpp:261:7:261:44 | deallocate | Taking the address of banned `std::pmr::memory_resource::deallocate`. |
73+
| test.cpp:265:13:266:19 | allocate | Taking the address of banned `std::pmr::polymorphic_allocator<C1>::allocate`. |
74+
| test.cpp:268:13:269:21 | deallocate | Taking the address of banned `std::pmr::polymorphic_allocator<C1>::deallocate`. |
75+
| test.cpp:273:13:274:24 | allocate | Taking the address of banned `std::pmr::memory_resource::allocate`. |
76+
| test.cpp:276:14:277:27 | deallocate | Taking the address of banned `std::pmr::memory_resource::deallocate`. |
77+
| test.cpp:281:14:282:25 | allocate | Taking the address of banned `std::pmr::memory_resource::allocate`. |
78+
| test.cpp:284:14:285:27 | deallocate | Taking the address of banned `std::pmr::memory_resource::deallocate`. |
79+
| test.cpp:289:14:290:25 | allocate | Taking the address of banned `std::pmr::memory_resource::allocate`. |
80+
| test.cpp:292:14:293:27 | deallocate | Taking the address of banned `std::pmr::memory_resource::deallocate`. |
81+
| test.cpp:299:7:299:28 | allocate | Taking the address of banned `std::scoped_allocator_adaptor<allocator<C1>>::allocate`. |
82+
| test.cpp:302:7:302:30 | deallocate | Taking the address of banned `std::scoped_allocator_adaptor<allocator<C1>>::deallocate`. |
83+
| test.cpp:309:13:309:41 | release | Taking the address of banned `std::unique_ptr<C1, default_delete<C1>>::release`. |
84+
| test.cpp:312:7:312:37 | release | Taking the address of banned `std::unique_ptr<C1[], default_delete<C1[]>>::release`. |

0 commit comments

Comments
 (0)