Skip to content

Commit 069f1f8

Browse files
committed
Extract StdNS to a library
A23-0-1 MSC51-CPP: update expected files
1 parent 7126819 commit 069f1f8

File tree

7 files changed

+61
-24
lines changed

7 files changed

+61
-24
lines changed

cpp/autosar/src/rules/A18-1-2/VectorboolSpecializationUsed.ql

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,7 @@
1717

1818
import cpp
1919
import codingstandards.cpp.autosar
20-
21-
class StdNS extends Namespace {
22-
StdNS() {
23-
this instanceof StdNamespace
24-
or
25-
this.isInline() and
26-
this.getParentNamespace() instanceof StdNS
27-
}
28-
}
20+
import codingstandards.cpp.StdNamespace
2921

3022
predicate isVectorBool(ClassTemplateInstantiation c) {
3123
c.getNamespace() instanceof StdNS and

cpp/autosar/src/rules/A18-1-3/AutoPtrTypeUsed.ql

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,10 @@
1515

1616
import cpp
1717
import codingstandards.cpp.autosar
18+
import codingstandards.cpp.StdNamespace
1819

1920
predicate isAutoPtr(ClassTemplateInstantiation c) {
20-
(
21-
c.getNamespace() instanceof StdNamespace
22-
or
23-
c.getNamespace().isInline() and
24-
c.getNamespace().getParentNamespace() instanceof StdNamespace
25-
) and
21+
c.getNamespace() instanceof StdNS and
2622
c.getSimpleName() = "auto_ptr"
2723
}
2824

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
| test.cpp:10:39:10:48 | call to __normal_iterator | Non-const version of container call immediately converted to a `const_iterator`. |
2+
| test.cpp:12:38:12:43 | call to cbegin | Non-const version of container call immediately converted to a `const_iterator`. |
3+
| test.cpp:13:38:13:42 | call to begin | Non-const version of container call immediately converted to a `const_iterator`. |
4+
| test.cpp:15:44:15:49 | call to cbegin | Non-const version of container call immediately converted to a `const_iterator`. |
5+
| test.cpp:16:44:16:48 | call to begin | Non-const version of container call immediately converted to a `const_iterator`. |
6+
| test.cpp:19:41:19:50 | call to _Rb_tree_const_iterator | Non-const version of container call immediately converted to a `const_iterator`. |
7+
| test.cpp:22:47:22:57 | call to _Rb_tree_const_iterator | Non-const version of container call immediately converted to a `const_iterator`. |
8+
| test.cpp:25:8:25:16 | call to __normal_iterator | Non-const version of container call immediately converted to a `const_iterator`. |
9+
| test.cpp:26:10:26:15 | call to cbegin | Non-const version of container call immediately converted to a `const_iterator`. |
10+
| test.cpp:27:10:27:14 | call to begin | Non-const version of container call immediately converted to a `const_iterator`. |
11+
| test.cpp:28:11:28:16 | call to cbegin | Non-const version of container call immediately converted to a `const_iterator`. |
12+
| test.cpp:29:11:29:15 | call to begin | Non-const version of container call immediately converted to a `const_iterator`. |
13+
| test.cpp:31:8:31:16 | call to _Rb_tree_const_iterator | Non-const version of container call immediately converted to a `const_iterator`. |
14+
| test.cpp:33:9:33:18 | call to _Rb_tree_const_iterator | Non-const version of container call immediately converted to a `const_iterator`. |
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
| test.cpp:10:39:10:48 | call to __normal_iterator | Non-const version of container call immediately converted to a `const_iterator`. |
2+
| test.cpp:12:38:12:43 | call to cbegin | Non-const version of container call immediately converted to a `const_iterator`. |
3+
| test.cpp:13:38:13:42 | call to begin | Non-const version of container call immediately converted to a `const_iterator`. |
4+
| test.cpp:15:44:15:49 | call to cbegin | Non-const version of container call immediately converted to a `const_iterator`. |
5+
| test.cpp:16:44:16:48 | call to begin | Non-const version of container call immediately converted to a `const_iterator`. |
6+
| test.cpp:19:41:19:50 | call to _Rb_tree_const_iterator | Non-const version of container call immediately converted to a `const_iterator`. |
7+
| test.cpp:22:47:22:57 | call to _Rb_tree_const_iterator | Non-const version of container call immediately converted to a `const_iterator`. |
8+
| test.cpp:25:8:25:16 | call to __normal_iterator | Non-const version of container call immediately converted to a `const_iterator`. |
9+
| test.cpp:26:10:26:15 | call to cbegin | Non-const version of container call immediately converted to a `const_iterator`. |
10+
| test.cpp:27:10:27:14 | call to begin | Non-const version of container call immediately converted to a `const_iterator`. |
11+
| test.cpp:28:11:28:16 | call to cbegin | Non-const version of container call immediately converted to a `const_iterator`. |
12+
| test.cpp:29:11:29:15 | call to begin | Non-const version of container call immediately converted to a `const_iterator`. |
13+
| test.cpp:31:8:31:16 | call to _Rb_tree_const_iterator | Non-const version of container call immediately converted to a `const_iterator`. |
14+
| test.cpp:33:9:33:18 | call to _Rb_tree_const_iterator | Non-const version of container call immediately converted to a `const_iterator`. |
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
| test.cpp:9:33:9:33 | call to linear_congruential_engine | Random number generator linear_congruential_engine is default-initialized and is therefore not properly seeded. |
2+
| test.cpp:10:30:10:31 | call to linear_congruential_engine | Random number generator linear_congruential_engine is default-initialized and is therefore not properly seeded. |
3+
| test.cpp:11:21:11:22 | call to linear_congruential_engine | Random number generator linear_congruential_engine is default-initialized and is therefore not properly seeded. |
4+
| test.cpp:12:20:12:21 | call to linear_congruential_engine | Random number generator linear_congruential_engine is default-initialized and is therefore not properly seeded. |
5+
| test.cpp:13:16:13:17 | call to mersenne_twister_engine | Random number generator mersenne_twister_engine is default-initialized and is therefore not properly seeded. |
6+
| test.cpp:14:19:14:20 | call to mersenne_twister_engine | Random number generator mersenne_twister_engine is default-initialized and is therefore not properly seeded. |
7+
| test.cpp:15:22:15:23 | call to subtract_with_carry_engine | Random number generator subtract_with_carry_engine is default-initialized and is therefore not properly seeded. |
8+
| test.cpp:16:22:16:23 | call to subtract_with_carry_engine | Random number generator subtract_with_carry_engine is default-initialized and is therefore not properly seeded. |
9+
| test.cpp:17:17:17:19 | call to discard_block_engine | Random number generator discard_block_engine is default-initialized and is therefore not properly seeded. |
10+
| test.cpp:18:17:18:19 | call to discard_block_engine | Random number generator discard_block_engine is default-initialized and is therefore not properly seeded. |
11+
| test.cpp:19:16:19:18 | call to shuffle_order_engine | Random number generator shuffle_order_engine is default-initialized and is therefore not properly seeded. |
12+
| test.cpp:21:34:22:47 | call to linear_congruential_engine | Random number generator linear_congruential_engine is initialized from std::time and is therefore not properly seeded. |
13+
| test.cpp:23:34:23:36 | call to linear_congruential_engine | Random number generator linear_congruential_engine is is initialized to the constant value 2 and is therefore not properly seeded. |
14+
| test.cpp:29:30:29:35 | default initialization engine of type default_random_engine | Random number generator linear_congruential_engine is default-initialized and is therefore not properly seeded. |
15+
| test.cpp:36:23:36:23 | call to linear_congruential_engine | Random number generator linear_congruential_engine is default-initialized and is therefore not properly seeded. |

cpp/common/src/codingstandards/cpp/Iterators.qll

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,7 @@
55
import cpp
66
import semmle.code.cpp.dataflow.DataFlow
77
import semmle.code.cpp.dataflow.TaintTracking
8-
9-
class StdNS extends Namespace {
10-
StdNS() {
11-
this instanceof StdNamespace
12-
or
13-
this.isInline() and
14-
this.getParentNamespace() instanceof StdNS
15-
}
16-
}
8+
import codingstandards.cpp.StdNamespace
179

1810
abstract class ContainerAccess extends VariableAccess {
1911
abstract Variable getOwningContainer();
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import cpp
2+
3+
/**
4+
* A class that models the `std` namespace and its inline children
5+
* (e.g. `std::_V2` `std::__cxx11` and `std::__1`)
6+
*/
7+
class StdNS extends Namespace {
8+
StdNS() {
9+
this instanceof StdNamespace
10+
or
11+
this.isInline() and
12+
this.getParentNamespace() instanceof StdNS
13+
}
14+
}

0 commit comments

Comments
 (0)