Skip to content

Commit 7af7e8c

Browse files
committed
Change labels of take_address_of_class_specific_* tests to NON_COMPLIANT[FALSE_NEGATIVE]
Also, clean up bits of alert message that's commented out.
1 parent 35854cf commit 7af7e8c

File tree

3 files changed

+60
-51
lines changed

3 files changed

+60
-51
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,14 @@ 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() +
80-
//"."
81-
"` which is " + advancedMemoryManagementFunction.describe() + "."
79+
"Call to banned function `" + advancedMemoryManagementFunction.getName() + "` which is " +
80+
advancedMemoryManagementFunction.describe() + "."
8281
or
8382
/* 2. The element takes address of the advanced memory management functions. */
8483
element = advancedMemoryManagementFunction.getAnAccess() and
8584
message =
8685
"Taking the address of a banned function `" + advancedMemoryManagementFunction.getName() +
8786
"` which is " + advancedMemoryManagementFunction.describe() + "."
88-
// "`."
8987
)
9088
or
9189
(

cpp/misra/test/rules/RULE-21-6-3/AdvancedMemoryManagementUsed.expected

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -60,29 +60,29 @@
6060
| test.cpp:281:7:281:23 | operator delete | Taking the address of a banned function `operator delete` which is a non-replaceable deallocation function. |
6161
| test.cpp:283:7:283:26 | operator delete[] | Taking the address of a banned function `operator delete[]` which is a non-replaceable deallocation function. |
6262
| test.cpp:285:7:285:25 | operator delete[] | Taking the address of a banned function `operator delete[]` which is a non-replaceable deallocation function. |
63-
| test.cpp:303:7:303:23 | operator new | Taking the address of a banned function `operator new` which is a non-replaceable allocation function. |
64-
| test.cpp:306:7:306:23 | operator new | Taking the address of a banned function `operator new` which is a non-replaceable allocation function. |
65-
| test.cpp:320:7:320:26 | operator delete | Taking the address of a banned function `operator delete` which is a non-replaceable deallocation function. |
66-
| test.cpp:323:7:323:28 | operator delete[] | Taking the address of a banned function `operator delete[]` which is a non-replaceable deallocation function. |
67-
| test.cpp:326:7:326:26 | operator delete | Taking the address of a banned function `operator delete` which is a non-replaceable deallocation function. |
68-
| test.cpp:340:3:340:38 | call to uninitialized_default_construct | Call to banned function `uninitialized_default_construct` which is a function from <memory> that manages uninitialized memory. |
69-
| test.cpp:341:3:341:40 | call to uninitialized_default_construct_n | Call to banned function `uninitialized_default_construct_n` which is a function from <memory> that manages uninitialized memory. |
70-
| test.cpp:354:3:354:36 | call to uninitialized_value_construct | Call to banned function `uninitialized_value_construct` which is a function from <memory> that manages uninitialized memory. |
71-
| test.cpp:355:3:355:38 | call to uninitialized_value_construct_n | Call to banned function `uninitialized_value_construct_n` which is a function from <memory> that manages uninitialized memory. |
72-
| test.cpp:367:3:367:25 | call to uninitialized_copy | Call to banned function `uninitialized_copy` which is a function from <memory> that manages uninitialized memory. |
73-
| test.cpp:368:3:368:27 | call to uninitialized_copy_n | Call to banned function `uninitialized_copy_n` which is a function from <memory> that manages uninitialized memory. |
74-
| test.cpp:380:3:380:25 | call to uninitialized_move | Call to banned function `uninitialized_move` which is a function from <memory> that manages uninitialized memory. |
75-
| test.cpp:381:3:381:27 | call to uninitialized_move_n | Call to banned function `uninitialized_move_n` which is a function from <memory> that manages uninitialized memory. |
76-
| test.cpp:394:3:394:25 | call to uninitialized_fill | Call to banned function `uninitialized_fill` which is a function from <memory> that manages uninitialized memory. |
77-
| test.cpp:395:3:395:27 | call to uninitialized_fill_n | Call to banned function `uninitialized_fill_n` which is a function from <memory> that manages uninitialized memory. |
78-
| test.cpp:407:3:407:38 | call to uninitialized_default_construct | Call to banned function `uninitialized_default_construct` which is a function from <memory> that manages uninitialized memory. |
79-
| test.cpp:409:3:409:14 | call to destroy | Call to banned function `destroy` which is a function from <memory> that manages uninitialized memory. |
80-
| test.cpp:410:3:410:16 | call to destroy_n | Call to banned function `destroy_n` which is a function from <memory> that manages uninitialized memory. |
81-
| test.cpp:411:3:411:17 | call to destroy_at | Call to banned function `destroy_at` which is a function from <memory> that manages uninitialized memory. |
82-
| test.cpp:419:12:419:26 | call to operator new | Call to banned function `operator new` which is a non-replaceable allocation function. |
83-
| test.cpp:420:3:420:11 | (vacuous destructor call) | Manual call to a destructor. |
84-
| test.cpp:421:12:421:26 | call to operator new | Call to banned function `operator new` which is a non-replaceable allocation function. |
85-
| test.cpp:423:12:423:23 | call to launder | Call to banned function `launder` which is a function from <memory> that manages uninitialized memory. |
86-
| test.cpp:433:3:433:10 | (vacuous destructor call) | Manual call to a destructor. |
87-
| test.cpp:443:3:443:11 | (vacuous destructor call) | Manual call to a destructor. |
88-
| test.cpp:454:5:454:16 | (vacuous destructor call) | Manual call to a destructor. |
63+
| test.cpp:308:7:308:23 | operator new | Taking the address of a banned function `operator new` which is a non-replaceable allocation function. |
64+
| test.cpp:311:7:311:23 | operator new | Taking the address of a banned function `operator new` which is a non-replaceable allocation function. |
65+
| test.cpp:331:7:331:26 | operator delete | Taking the address of a banned function `operator delete` which is a non-replaceable deallocation function. |
66+
| test.cpp:334:7:334:28 | operator delete[] | Taking the address of a banned function `operator delete[]` which is a non-replaceable deallocation function. |
67+
| test.cpp:337:7:337:26 | operator delete | Taking the address of a banned function `operator delete` which is a non-replaceable deallocation function. |
68+
| test.cpp:351:3:351:38 | call to uninitialized_default_construct | Call to banned function `uninitialized_default_construct` which is a function from <memory> that manages uninitialized memory. |
69+
| test.cpp:352:3:352:40 | call to uninitialized_default_construct_n | Call to banned function `uninitialized_default_construct_n` which is a function from <memory> that manages uninitialized memory. |
70+
| test.cpp:365:3:365:36 | call to uninitialized_value_construct | Call to banned function `uninitialized_value_construct` which is a function from <memory> that manages uninitialized memory. |
71+
| test.cpp:366:3:366:38 | call to uninitialized_value_construct_n | Call to banned function `uninitialized_value_construct_n` which is a function from <memory> that manages uninitialized memory. |
72+
| test.cpp:378:3:378:25 | call to uninitialized_copy | Call to banned function `uninitialized_copy` which is a function from <memory> that manages uninitialized memory. |
73+
| test.cpp:379:3:379:27 | call to uninitialized_copy_n | Call to banned function `uninitialized_copy_n` which is a function from <memory> that manages uninitialized memory. |
74+
| test.cpp:391:3:391:25 | call to uninitialized_move | Call to banned function `uninitialized_move` which is a function from <memory> that manages uninitialized memory. |
75+
| test.cpp:392:3:392:27 | call to uninitialized_move_n | Call to banned function `uninitialized_move_n` which is a function from <memory> that manages uninitialized memory. |
76+
| test.cpp:405:3:405:25 | call to uninitialized_fill | Call to banned function `uninitialized_fill` which is a function from <memory> that manages uninitialized memory. |
77+
| test.cpp:406:3:406:27 | call to uninitialized_fill_n | Call to banned function `uninitialized_fill_n` which is a function from <memory> that manages uninitialized memory. |
78+
| test.cpp:418:3:418:38 | call to uninitialized_default_construct | Call to banned function `uninitialized_default_construct` which is a function from <memory> that manages uninitialized memory. |
79+
| test.cpp:420:3:420:14 | call to destroy | Call to banned function `destroy` which is a function from <memory> that manages uninitialized memory. |
80+
| test.cpp:421:3:421:16 | call to destroy_n | Call to banned function `destroy_n` which is a function from <memory> that manages uninitialized memory. |
81+
| test.cpp:422:3:422:17 | call to destroy_at | Call to banned function `destroy_at` which is a function from <memory> that manages uninitialized memory. |
82+
| test.cpp:430:12:430:26 | call to operator new | Call to banned function `operator new` which is a non-replaceable allocation function. |
83+
| test.cpp:431:3:431:11 | (vacuous destructor call) | Manual call to a destructor. |
84+
| test.cpp:432:12:432:26 | call to operator new | Call to banned function `operator new` which is a non-replaceable allocation function. |
85+
| test.cpp:434:12:434:23 | call to launder | Call to banned function `launder` which is a function from <memory> that manages uninitialized memory. |
86+
| test.cpp:444:3:444:10 | (vacuous destructor call) | Manual call to a destructor. |
87+
| test.cpp:454:3:454:11 | (vacuous destructor call) | Manual call to a destructor. |
88+
| test.cpp:465:5:465:16 | (vacuous destructor call) | Manual call to a destructor. |

cpp/misra/test/rules/RULE-21-6-3/test.cpp

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -287,44 +287,55 @@ void take_address_of_placement_delete() {
287287
}
288288

289289
/**
290-
* Test taking address of class-specific operator new.
290+
* Test taking address of class-specific `operator new`s.
291+
* These are non-compliant overloads of the operator, but
292+
* These depend on the non-compliant operators being defined
293+
* in the first place (note that member functions need to be
294+
* implemented, beyond declared, to have an address).
291295
*/
292296
void take_address_of_class_specific_new() {
293297
void *(*p1)(std::size_t) =
294-
&C1::operator new; // COMPLIANT: address of class-specific replaceable
295-
// allocation function
298+
&C1::operator new; // NON_COMPLIANT[FALSE_NEGATIVE]: address of
299+
// class-specific replaceable allocation function
296300
void *(*p2)(std::size_t) =
297-
&C1::operator new[]; // COMPLIANT: address of class-specific replaceable
298-
// allocation function
301+
&C1::operator new[]; // NON_COMPLIANT[FALSE_NEGATIVE]: address of
302+
// class-specific replaceable allocation function
299303
void *(*p3)(std::size_t, const std::nothrow_t &) =
300-
&C1::operator new; // COMPLIANT: address of class-specific replaceable
301-
// non-throwing allocation function
304+
&C1::operator new; // NON_COMPLIANT[FALSE_NEGATIVE]: address of
305+
// class-specific replaceable non-throwing allocation
306+
// function
302307
void *(*p4)(std::size_t, void *) =
303-
&C1::operator new; // NON_COMPLIANT: address of class-specific placement
304-
// new
308+
&C1::operator new; // NON_COMPLIANT[FALSE_NEGATIVE]: address of
309+
// class-specific placement new
305310
void *(*p5)(std::size_t, int) =
306-
&C1::operator new; // NON_COMPLIANT: address of class-specific custom new
311+
&C1::operator new; // NON_COMPLIANT[FALSE_NEGATIVE]: address of
312+
// class-specific custom new
307313
}
308314

309315
/**
310-
* Test taking address of class-specific operator delete.
316+
* Test taking address of class-specific `operator delete`s.
317+
* These are non-compliant overloads of the operator, but
318+
* These depend on the non-compliant operators being defined
319+
* in the first place (note that member functions need to be
320+
* implemented, beyond declared, to have an address).
311321
*/
312322
void take_address_of_class_specific_delete() {
313323
void (*p1)(void *) =
314-
&C1::operator delete; // COMPLIANT: address of class-specific
315-
// replaceable deallocation function
324+
&C1::operator delete; // NON_COMPLIANT[FALSE_NEGATIVE]: address of
325+
// class-specific replaceable deallocation function
316326
void (*p2)(void *) =
317-
&C1::operator delete[]; // COMPLIANT: address of class-specific
318-
// replaceable deallocation function
327+
&C1::operator delete[]; // NON_COMPLIANT[FALSE_NEGATIVE]: address of
328+
// class-specific replaceable deallocation
329+
// function
319330
void (*p3)(void *, void *) =
320-
&C1::operator delete; // NON_COMPLIANT: address of class-specific
321-
// placement delete
331+
&C1::operator delete; // NON_COMPLIANT[FALSE_NEGATIVE]: address of
332+
// class-specific placement delete
322333
void (*p4)(void *, void *) =
323-
&C1::operator delete[]; // NON_COMPLIANT: address of class-specific
324-
// placement delete[]
334+
&C1::operator delete[]; // NON_COMPLIANT[FALSE_NEGATIVE]: address of
335+
// class-specific placement delete[]
325336
void (*p5)(void *, int) =
326-
&C1::operator delete; // NON_COMPLIANT: address of class-specific custom
327-
// delete
337+
&C1::operator delete; // NON_COMPLIANT[FALSE_NEGATIVE]: address of
338+
// class-specific custom delete
328339
}
329340

330341
/**

0 commit comments

Comments
 (0)