Skip to content

Commit fe33f61

Browse files
Autoformat cpp, fix test expectations
1 parent dae4d25 commit fe33f61

File tree

2 files changed

+82
-79
lines changed

2 files changed

+82
-79
lines changed
Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
1-
| test.cpp:10:11:10:12 | 0 | Unnecessary write to object $@ is never observed. | test.cpp:10:7:10:8 | l0 | l0 |
2-
| test.cpp:60:12:60:13 | 0 | Unnecessary write to object $@ is never observed. | test.cpp:60:7:60:9 | l13 | l13 |
3-
| test.cpp:61:3:61:5 | l13 | Unnecessary write to object $@ is never observed. | test.cpp:60:7:60:9 | l13 | l13 |
4-
| test.cpp:116:6:116:9 | ... -- | Unnecessary write to object $@ is never observed. | test.cpp:115:7:115:8 | l2 | l2 |
5-
| test.cpp:118:6:118:9 | ... ++ | Unnecessary write to object $@ is never observed. | test.cpp:117:7:117:8 | l3 | l3 |
6-
| test.cpp:126:11:126:12 | 0 | Unnecessary write to object $@ is not read before subsequent writes. | test.cpp:126:7:126:8 | l0 | l0 |
7-
| test.cpp:141:20:141:20 | second | Unnecessary write to object $@ is never observed. | test.cpp:141:13:141:13 | l1 | l1 |
8-
| test.cpp:149:18:149:18 | call to operator* | Unnecessary write to object $@ is never observed. | test.cpp:149:13:149:14 | l3 | l3 |
9-
| test.cpp:167:13:167:22 | new | Unnecessary write to object $@ is never observed. | test.cpp:167:8:167:9 | l3 | l3 |
10-
| test.cpp:172:11:172:12 | 1 | Unnecessary write to object $@ is never observed. | test.cpp:172:7:172:8 | l1 | l1 |
11-
| test.cpp:178:11:178:12 | 1 | Unnecessary write to object $@ is never observed. | test.cpp:178:7:178:8 | l1 | l1 |
12-
| test.cpp:199:15:199:24 | 0 | Unnecessary write to object $@ is never observed. | test.cpp:199:11:199:12 | t0 | t0 |
13-
| test.cpp:218:15:218:24 | 0 | Unnecessary write to object $@ is never observed. | test.cpp:218:11:218:12 | t4 | t4 |
14-
| test.cpp:219:17:219:29 | new | Unnecessary write to object $@ is never observed. | test.cpp:219:12:219:13 | t5 | t5 |
15-
| test.cpp:222:6:222:6 | a | Unnecessary write to object $@ is never observed. | test.cpp:221:11:221:12 | t6 | t6 |
16-
| test.cpp:235:16:235:25 | 0 | Unnecessary write to object $@ is never observed. | test.cpp:235:11:235:13 | t10 | t10 |
17-
| test.cpp:238:18:238:30 | new | Unnecessary write to object $@ is never observed. | test.cpp:238:12:238:14 | t11 | t11 |
18-
| test.cpp:241:18:241:40 | {...} | Unnecessary write to object $@ is never observed. | test.cpp:241:11:241:13 | t12 | t12 |
19-
| test.cpp:255:13:255:14 | l0 | Unnecessary write to object $@ is never observed. | test.cpp:255:8:255:9 | l1 | l1 |
20-
| test.cpp:265:4:265:7 | ... ++ | Unnecessary write to object $@ is never observed. | test.cpp:264:8:264:9 | l4 | l4 |
21-
| test.cpp:280:6:280:6 | a | Unnecessary write to object $@ is not read before subsequent writes. | test.cpp:275:11:275:12 | t0 | t0 |
22-
| test.cpp:284:6:284:6 | a | Unnecessary write to object $@ is not read before subsequent writes. | test.cpp:275:11:275:12 | t0 | t0 |
23-
| test.cpp:300:8:300:8 | a | Unnecessary write to object $@ is not read before subsequent writes. | test.cpp:299:5:299:6 | t2 | t2 |
24-
| test.cpp:311:24:311:33 | call to vector | Unnecessary write to object $@ is never observed. | test.cpp:311:20:311:21 | v1 | v1 |
25-
| test.cpp:317:20:317:21 | call to vector | Unnecessary write to object $@ is never observed. | test.cpp:317:20:317:21 | v3 | v3 |
26-
| test.cpp:318:5:318:5 | call to operator[] | Unnecessary write to object $@ is never observed. | test.cpp:317:20:317:21 | v3 | v3 |
27-
| test.cpp:326:5:326:5 | call to operator[] | Unnecessary write to object $@ is not read before subsequent writes. | test.cpp:325:20:325:21 | v5 | v5 |
28-
| test.cpp:345:29:345:51 | call to vector | Unnecessary write to object $@ is never observed. | test.cpp:345:24:345:26 | v10 | v10 |
29-
| test.cpp:355:3:355:4 | p1 | Unnecessary write to object $@ is never observed. | test.cpp:351:22:351:23 | p1 | p1 |
30-
| test.cpp:362:6:362:6 | a | Unnecessary write to object $@ is never observed. | test.cpp:358:30:358:31 | t1 | t1 |
31-
| test.cpp:372:5:372:5 | call to operator[] | Unnecessary write to object $@ is never observed. | test.cpp:367:56:367:57 | v1 | v1 |
32-
| test.cpp:387:3:387:4 | p1 | Unnecessary write to object $@ is never observed. | test.cpp:377:24:377:25 | p1 | p1 |
33-
| test.cpp:388:3:388:4 | p2 | Unnecessary write to object $@ is never observed. | test.cpp:377:37:377:38 | p2 | p2 |
34-
| test.cpp:389:3:389:4 | p3 | Unnecessary write to object $@ is never observed. | test.cpp:377:53:377:54 | p3 | p3 |
35-
| test.cpp:390:3:390:4 | p4 | Unnecessary write to object $@ is never observed. | test.cpp:378:32:378:33 | p4 | p4 |
36-
| test.cpp:404:13:404:22 | {...} | Unnecessary write to object $@ is never observed. | test.cpp:404:7:404:8 | l1 | l1 |
37-
| test.cpp:409:17:409:39 | {...} | Unnecessary write to object $@ is never observed. | test.cpp:409:11:409:12 | l3 | l3 |
38-
| test.cpp:420:3:420:7 | access to array | Unnecessary write to object $@ is not read before subsequent writes. | test.cpp:419:7:419:8 | l6 | l6 |
39-
| test.cpp:425:3:425:9 | access to array | Unnecessary write to object $@ is not read before subsequent writes. | test.cpp:424:7:424:10 | l6_1 | l6_1 |
40-
| test.cpp:441:3:441:7 | access to array | Unnecessary write to object $@ is never observed. | test.cpp:440:7:440:8 | l9 | l9 |
41-
| test.cpp:442:3:442:7 | access to array | Unnecessary write to object $@ is never observed. | test.cpp:440:7:440:8 | l9 | l9 |
42-
| test.cpp:443:3:443:7 | access to array | Unnecessary write to object $@ is never observed. | test.cpp:440:7:440:8 | l9 | l9 |
43-
| test.cpp:451:3:451:8 | access to array | Unnecessary write to object $@ is never observed. | test.cpp:450:7:450:9 | l11 | l11 |
44-
| test.cpp:452:3:452:10 | ... ++ | Unnecessary write to object $@ is never observed. | test.cpp:450:7:450:9 | l11 | l11 |
45-
| test.cpp:516:7:516:7 | call to operator[] | Unnecessary write to object $@ is not read before subsequent writes. | test.cpp:515:22:515:23 | v7 | v7 |
46-
| test.cpp:558:13:558:19 | 0 | Unnecessary write to object $@ is never observed. | test.cpp:558:8:558:9 | l0 | l0 |
47-
| test.cpp:560:13:560:19 | 0 | Unnecessary write to object $@ is never observed. | test.cpp:560:8:560:9 | l1 | l1 |
1+
| test.cpp:10:11:10:12 | 0 | Unnecessary write to object $@ is never observed. | test.cpp:10:7:10:8 | l0 | l0 |
2+
| test.cpp:60:12:60:13 | 0 | Unnecessary write to object $@ is never observed. | test.cpp:60:7:60:9 | l13 | l13 |
3+
| test.cpp:61:3:61:5 | l13 | Unnecessary write to object $@ is never observed. | test.cpp:60:7:60:9 | l13 | l13 |
4+
| test.cpp:116:6:116:9 | ... -- | Unnecessary write to object $@ is never observed. | test.cpp:115:7:115:8 | l2 | l2 |
5+
| test.cpp:118:6:118:9 | ... ++ | Unnecessary write to object $@ is never observed. | test.cpp:117:7:117:8 | l3 | l3 |
6+
| test.cpp:126:11:126:12 | 0 | Unnecessary write to object $@ is not read before subsequent writes. | test.cpp:126:7:126:8 | l0 | l0 |
7+
| test.cpp:141:20:141:20 | second | Unnecessary write to object $@ is never observed. | test.cpp:141:13:141:13 | l1 | l1 |
8+
| test.cpp:149:18:149:18 | call to operator* | Unnecessary write to object $@ is never observed. | test.cpp:149:13:149:14 | l3 | l3 |
9+
| test.cpp:167:13:167:22 | new | Unnecessary write to object $@ is never observed. | test.cpp:167:8:167:9 | l3 | l3 |
10+
| test.cpp:172:11:172:12 | 1 | Unnecessary write to object $@ is never observed. | test.cpp:172:7:172:8 | l1 | l1 |
11+
| test.cpp:178:11:178:12 | 1 | Unnecessary write to object $@ is never observed. | test.cpp:178:7:178:8 | l1 | l1 |
12+
| test.cpp:199:15:199:24 | 0 | Unnecessary write to object $@ is never observed. | test.cpp:199:11:199:12 | t0 | t0 |
13+
| test.cpp:218:15:218:24 | 0 | Unnecessary write to object $@ is never observed. | test.cpp:218:11:218:12 | t4 | t4 |
14+
| test.cpp:219:17:219:29 | new | Unnecessary write to object $@ is never observed. | test.cpp:219:12:219:13 | t5 | t5 |
15+
| test.cpp:222:6:222:6 | a | Unnecessary write to object $@ is never observed. | test.cpp:221:11:221:12 | t6 | t6 |
16+
| test.cpp:235:16:235:25 | 0 | Unnecessary write to object $@ is never observed. | test.cpp:235:11:235:13 | t10 | t10 |
17+
| test.cpp:238:18:238:30 | new | Unnecessary write to object $@ is never observed. | test.cpp:238:12:238:14 | t11 | t11 |
18+
| test.cpp:241:18:241:40 | {...} | Unnecessary write to object $@ is never observed. | test.cpp:241:11:241:13 | t12 | t12 |
19+
| test.cpp:255:13:255:14 | l0 | Unnecessary write to object $@ is never observed. | test.cpp:255:8:255:9 | l1 | l1 |
20+
| test.cpp:265:4:265:7 | ... ++ | Unnecessary write to object $@ is never observed. | test.cpp:264:8:264:9 | l4 | l4 |
21+
| test.cpp:280:6:280:6 | a | Unnecessary write to object $@ is not read before subsequent writes. | test.cpp:275:11:275:12 | t0 | t0 |
22+
| test.cpp:284:6:284:6 | a | Unnecessary write to object $@ is not read before subsequent writes. | test.cpp:275:11:275:12 | t0 | t0 |
23+
| test.cpp:300:8:300:8 | a | Unnecessary write to object $@ is not read before subsequent writes. | test.cpp:299:5:299:6 | t2 | t2 |
24+
| test.cpp:311:24:311:33 | call to vector | Unnecessary write to object $@ is never observed. | test.cpp:311:20:311:21 | v1 | v1 |
25+
| test.cpp:317:20:317:21 | call to vector | Unnecessary write to object $@ is never observed. | test.cpp:317:20:317:21 | v3 | v3 |
26+
| test.cpp:318:5:318:5 | call to operator[] | Unnecessary write to object $@ is never observed. | test.cpp:317:20:317:21 | v3 | v3 |
27+
| test.cpp:326:5:326:5 | call to operator[] | Unnecessary write to object $@ is not read before subsequent writes. | test.cpp:325:20:325:21 | v5 | v5 |
28+
| test.cpp:345:29:345:51 | call to vector | Unnecessary write to object $@ is never observed. | test.cpp:345:24:345:26 | v10 | v10 |
29+
| test.cpp:355:3:355:4 | p1 | Unnecessary write to object $@ is never observed. | test.cpp:351:22:351:23 | p1 | p1 |
30+
| test.cpp:362:6:362:6 | a | Unnecessary write to object $@ is never observed. | test.cpp:358:30:358:31 | t1 | t1 |
31+
| test.cpp:372:5:372:5 | call to operator[] | Unnecessary write to object $@ is never observed. | test.cpp:367:56:367:57 | v1 | v1 |
32+
| test.cpp:387:3:387:4 | p1 | Unnecessary write to object $@ is never observed. | test.cpp:377:24:377:25 | p1 | p1 |
33+
| test.cpp:388:3:388:4 | p2 | Unnecessary write to object $@ is never observed. | test.cpp:377:37:377:38 | p2 | p2 |
34+
| test.cpp:389:3:389:4 | p3 | Unnecessary write to object $@ is never observed. | test.cpp:377:53:377:54 | p3 | p3 |
35+
| test.cpp:390:3:390:4 | p4 | Unnecessary write to object $@ is never observed. | test.cpp:378:32:378:33 | p4 | p4 |
36+
| test.cpp:404:13:404:22 | {...} | Unnecessary write to object $@ is never observed. | test.cpp:404:7:404:8 | l1 | l1 |
37+
| test.cpp:409:17:409:39 | {...} | Unnecessary write to object $@ is never observed. | test.cpp:409:11:409:12 | l3 | l3 |
38+
| test.cpp:420:3:420:7 | access to array | Unnecessary write to object $@ is not read before subsequent writes. | test.cpp:419:7:419:8 | l6 | l6 |
39+
| test.cpp:425:3:425:9 | access to array | Unnecessary write to object $@ is not read before subsequent writes. | test.cpp:424:7:424:10 | l6_1 | l6_1 |
40+
| test.cpp:441:3:441:7 | access to array | Unnecessary write to object $@ is never observed. | test.cpp:440:7:440:8 | l9 | l9 |
41+
| test.cpp:442:3:442:7 | access to array | Unnecessary write to object $@ is never observed. | test.cpp:440:7:440:8 | l9 | l9 |
42+
| test.cpp:443:3:443:7 | access to array | Unnecessary write to object $@ is never observed. | test.cpp:440:7:440:8 | l9 | l9 |
43+
| test.cpp:451:3:451:8 | access to array | Unnecessary write to object $@ is never observed. | test.cpp:450:7:450:9 | l11 | l11 |
44+
| test.cpp:452:3:452:10 | ... ++ | Unnecessary write to object $@ is never observed. | test.cpp:450:7:450:9 | l11 | l11 |
45+
| test.cpp:516:7:516:7 | call to operator[] | Unnecessary write to object $@ is not read before subsequent writes. | test.cpp:515:22:515:23 | v7 | v7 |
46+
| test.cpp:558:13:558:19 | 0 | Unnecessary write to object $@ is never observed. | test.cpp:558:8:558:9 | l0 | l0 |
47+
| test.cpp:560:13:560:19 | 0 | Unnecessary write to object $@ is never observed. | test.cpp:560:8:560:9 | l1 | l1 |

cpp/misra/test/rules/RULE-0-1-1/test.cpp

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ void f16() {
315315
useVec(v2);
316316

317317
std::vector<int> v3; // NON_COMPLIANT -- unobserved
318-
v3[0] = 0; // NON_COMPLIANT -- unused
318+
v3[0] = 0; // NON_COMPLIANT -- unused
319319

320320
std::vector<int> v4;
321321
v4[0] = 0; // COMPLIANT
@@ -422,10 +422,10 @@ void f21() {
422422
f0(l6[0]); // Observes entire object
423423

424424
int l6_1[10];
425-
l6_1[0] = 0; // NON_COMPLIANT
425+
l6_1[0] = 0; // NON_COMPLIANT
426426
l6_1[1] = l6_1[2]; // COMPLIANT
427-
l6_1[0] = 0; // COMPLIANT
428-
f0(l6_1[0]); // Observes entire object
427+
l6_1[0] = 0; // COMPLIANT
428+
f0(l6_1[0]); // Observes entire object
429429

430430
int l7[10];
431431
l7[0] = 0; // COMPLIANT
@@ -570,18 +570,18 @@ void f24() {
570570
l1[l0 + 1] = 0; // COMPLIANT
571571
useVec(l1);
572572

573-
int l2 = 0; // COMPLIANT
574-
int *l3; // COMPLIANT
573+
int l2 = 0; // COMPLIANT
574+
int *l3; // COMPLIANT
575575
l3[l2 * 2] = 0; // COMPLIANT
576576
f0(l3[0]);
577-
577+
578578
int l4 = 0; // COMPLIANT
579579
int l5[10];
580580
l5[l4 % 10] = 0; // COMPLIANT
581581
f0(l5[0]);
582582

583-
int l6 = 0; // COMPLIANT
584-
Trivial *l7; // COMPLIANT
583+
int l6 = 0; // COMPLIANT
584+
Trivial *l7; // COMPLIANT
585585
l7[l6 & 3].a = 0; // COMPLIANT
586586
use(l7[0]);
587587

@@ -609,36 +609,36 @@ void f25() {
609609
f0(*l1);
610610

611611
// False positive case
612-
int l2 = 0; // COMPLIANT
612+
int l2 = 0; // COMPLIANT
613613
int *l3 = &l2; // COMPLIANT
614614
f0(*l3);
615615
l2 = 1; // NON_COMPLIANT[False negative] -- not observed
616616

617617
// True positive case
618618
// Handles case where l4 is written twice without read
619-
int l4 = 0; // COMPLIANT
619+
int l4 = 0; // COMPLIANT
620620
int *l5 = &l4; // COMPLIANT
621-
l4 = 1; // COMPLIANT
621+
l4 = 1; // COMPLIANT
622622
f0(*l5);
623623
l4 = 2; // COMPLIANT
624624
f0(l4); // observe l4
625625

626626
// False positive case
627627
// Handles case where l6 is written twice without read
628-
int l6 = 0; // COMPLIANT
628+
int l6 = 0; // COMPLIANT
629629
int *l7 = &l6; // COMPLIANT
630630
f0(*l7);
631631
l6 = 1; // NON_COMPLIANT[False negative]
632632
l6 = 2; // COMPLIANT
633633
f0(l6); // observe l6
634634

635635
// Test reference variables
636-
int l8 = 0; // COMPLIANT
636+
int l8 = 0; // COMPLIANT
637637
int &l9 = l8; // COMPLIANT
638-
l8 = 1; // COMPLIANT
638+
l8 = 1; // COMPLIANT
639639
f0(l9);
640640

641-
int l10 = 0; // COMPLIANT
641+
int l10 = 0; // COMPLIANT
642642
int &l11 = l10; // COMPLIANT
643643
f0(l11);
644644
l10 = 1; // NON_COMPLIANT[False negative]
@@ -647,38 +647,41 @@ void f25() {
647647
void f26() {
648648
/**
649649
* The following tests show the limitations of our STL container modeling.
650-
*
650+
*
651651
* These FNs are preferred over FPs.
652652
*/
653653
std::vector<int> v0 = {0, 1, 2}; // COMPLIANT[False negative]
654654
v0.size(); // finding size is currently treated as observes whole object
655655

656656
std::vector<int> v1 = {0, 1, 2}; // NON_COMPLIANT[False negative]
657-
v1.begin(); // obtaining iterator is currently treated as observing whole object
657+
v1.begin(); // obtaining iterator is currently treated as observing whole
658+
// object
658659

659660
std::vector<int> v2 = {0, 1, 2}; // NON_COMPLIANT[False negative]
660661
v2.end(); // obtaining iterator is currently treated as observing whole object
661662

662663
std::vector<int> v3 = {0, 1, 2}; // NON_COMPLIANT[False negative]
663-
v3.empty(); // checking emptiness is currently treated as observing whole object
664+
v3.empty(); // checking emptiness is currently treated as observing whole
665+
// object
664666

665-
//std::vector<int> v4 = {0, 1, 2}; // COMPLIANT[False negative]
666-
//v4.capacity(); // checking capacity is currently treated as observing whole object
667+
// std::vector<int> v4 = {0, 1, 2}; // COMPLIANT[False negative]
668+
// v4.capacity(); // checking capacity is currently treated as observing whole
669+
// object
667670

668671
/**
669672
* Testing calls to methods that modify the container.
670-
*
673+
*
671674
* These could be treated as a possible assignment to any index of that
672675
* container. Therefore, never treated as an overwrite, but must be observed.
673-
*
676+
*
674677
* This is not currently modeled, so all are FNs.
675678
*/
676679
std::vector<int> v5 = {0, 1, 2}; // NON_COMPLIANT[False negative]
677680
// We don't model that this must modify indexes 0 through 2.
678681
v5.clear(); // NON_COMPLIANT[False negative] -- not observed
679682

680683
std::vector<int> v6 = {0, 1, 2}; // NON_COMPLIANT[False negative]
681-
v6.clear(); // COMPLIANT -- observed
684+
v6.clear(); // COMPLIANT -- observed
682685
useVec(v6);
683686

684687
std::vector<int> v7 = {0, 1, 2}; // NON_COMPLIANT[False negative]
@@ -690,12 +693,12 @@ void f26() {
690693
std::vector<int> v9 = {0, 1, 2}; // NON_COMPLIANT[False negative]
691694
v9.pop_back(); // NON_COMPLIANT[False negative] -- not observed
692695

693-
//std::vector<int> v10 = {0, 1, 2}; // NON_COMPLIANT[False negative]
694-
//v10.assign(5, 0); // NON_COMPLIANT[False negative] -- not observed
696+
// std::vector<int> v10 = {0, 1, 2}; // NON_COMPLIANT[False negative]
697+
// v10.assign(5, 0); // NON_COMPLIANT[False negative] -- not observed
695698

696-
//std::vector<int> v11 = {0, 1, 2}; // NON_COMPLIANT[False negative]
697-
//std::vector<int> v12 = {3, 4, 5}; // NON_COMPLIANT[False negative]
698-
//v11.swap(v12); // NON_COMPLIANT[False negative] -- not observed
699+
// std::vector<int> v11 = {0, 1, 2}; // NON_COMPLIANT[False negative]
700+
// std::vector<int> v12 = {3, 4, 5}; // NON_COMPLIANT[False negative]
701+
// v11.swap(v12); // NON_COMPLIANT[False negative] -- not observed
699702

700703
std::vector<int> v13 = {0, 1, 2}; // NON_COMPLIANT[False negative]
701704
v13.emplace(v13.begin(), 3); // NON_COMPLIANT[False negative] -- not observed
@@ -706,13 +709,13 @@ void f26() {
706709
std::vector<int> v15 = {0, 1, 2}; // NON_COMPLIANT[False negative]
707710
v15.insert(v15.begin(), 3); // NON_COMPLIANT[False negative] -- not observed
708711

709-
//std::vector<int> v16 = {0, 1, 2}; // NON_COMPLIANT[False negative]
710-
//v16.erase(v16.begin()); // NON_COMPLIANT[False negative] -- not observed
712+
// std::vector<int> v16 = {0, 1, 2}; // NON_COMPLIANT[False negative]
713+
// v16.erase(v16.begin()); // NON_COMPLIANT[False negative] -- not observed
711714
}
712715

713716
void f27() {
714717
// Lambdas have been excluded for now for simplicity.
715-
int l0 = 0; // COMPLIANT
718+
int l0 = 0; // COMPLIANT
716719
auto l1 = [&l0]() { return l0 + 1; }; // COMPLIANT
717720
f0(l1());
718721

0 commit comments

Comments
 (0)