Skip to content

Commit 7fa5a5e

Browse files
authored
Merge branch 'main' into knewbury01/A18-0-1-improvements
2 parents ba85afc + d087031 commit 7fa5a5e

17 files changed

+218
-11
lines changed

.vscode/tasks.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,28 @@
140140
},
141141
"problemMatcher": []
142142
},
143+
{
144+
"label": "🧪 Standards Automation: Build Case Test DB from test file",
145+
"type": "shell",
146+
"windows": {
147+
"command": ".${pathSeparator}scripts${pathSeparator}.venv${pathSeparator}Scripts${pathSeparator}python.exe scripts${pathSeparator}build_test_database.py ${file}"
148+
},
149+
"linux": {
150+
"command": ".${pathSeparator}scripts${pathSeparator}.venv${pathSeparator}bin${pathSeparator}python3 scripts${pathSeparator}build_test_database.py ${file}"
151+
},
152+
"osx": {
153+
"command": ".${pathSeparator}scripts${pathSeparator}.venv${pathSeparator}bin${pathSeparator}python3 scripts${pathSeparator}build_test_database.py ${file}"
154+
},
155+
"presentation": {
156+
"reveal": "always",
157+
"panel": "new",
158+
"focus": true
159+
},
160+
"runOptions": {
161+
"reevaluateOnRerun": false
162+
},
163+
"problemMatcher": []
164+
},
143165
{
144166
"label": "📝 Standards Automation: Format CodeQL",
145167
"type": "shell",
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
`M8-5-2` - `AggregateLiteralEnhancements.qll`:
2+
- recognise aggregate literals initialized with parameters from variadic templates.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- `A2-10-1`, `RULE-5-3`:
2+
- Reduce false positives by considering point of declaration for local variables.
3+
- Reduce false negatives by considering catch block parameters to be in scope in the catch block.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- `M6-5-5`:
2+
- Reduce false positives by no longer considering the taking of a const reference as a modification.
3+
- Improve detection of non-local modification of loop iteration variables to reduce false positives.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
`M5-2-10` - `IncrementAndDecrementOperatorsMixedWithOtherOperatorsInExpression.ql`:
2+
- only report use of the increment and decrement operations in conjunction with arithmetic operators, as specified by the rule. Notably we no longer report the expressions of the form `*p++`, which combine increment and dereferencing operations.

cpp/autosar/src/rules/M5-2-10/IncrementAndDecrementOperatorsMixedWithOtherOperatorsInExpression.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616

1717
import cpp
1818
import codingstandards.cpp.autosar
19+
import codingstandards.cpp.Expr
1920

20-
from CrementOperation cop, Operation op, string name
21+
from CrementOperation cop, ArithmeticOperation op, string name
2122
where
2223
not isExcluded(cop) and
2324
not isExcluded(op,

cpp/autosar/test/rules/M5-2-10/test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ void f1() {
66
++l1; // COMPLIANT
77
--l2; // COMPLIANT
88
l3 = l1 * l2;
9+
int *p;
10+
*p++; // COMPLIANT - * is not an arithmetic operator
911
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
| test.cpp:24:8:24:15 | testFlag | Loop control variable testFlag is modified in the loop update expression. |
2+
| test.cpp:47:12:47:12 | y | Loop control variable y is modified in the loop update expression. |

cpp/autosar/test/rules/M6-5-5/test.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,27 @@ void test_loop_control_variable_modified_in_expression() {
2424
testFlag = updateFlagWithIncrement(++x)) { // NON_COMPLIANT
2525
}
2626
}
27+
28+
#include <vector>
29+
30+
void test_const_refs(std::vector<int> v) {
31+
std::vector<int>::iterator first = v.begin();
32+
std::vector<int>::iterator last = v.end();
33+
// call to operator!= passes a const reference to first
34+
for (; first != last; first++) { // COMPLIANT
35+
}
36+
}
37+
38+
void update(std::vector<int>::iterator &f, const int &x, int &y) {}
39+
40+
void test_const_refs_update(std::vector<int> v) {
41+
std::vector<int>::iterator last = v.end();
42+
int x = 0;
43+
int y = 0;
44+
// call to operator!= passes a const reference to first
45+
for (std::vector<int>::iterator first = v.begin(); first != last; update(
46+
first, x, // COMPLIANT - first is a loop counter, so can be modified
47+
y)) { // NON_COMPLIANT - y is modified and is not a loop counter
48+
first + 1;
49+
}
50+
}

cpp/autosar/test/rules/M8-5-2/test.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,13 @@ void test() {
5555
Bar b2{{0}}; // NON_COMPLIANT - missing explicit init, nested zero init
5656
StructNested n{}; // COMPLIANT
5757
StructNested n1 = {}; // COMPLIANT
58-
}
58+
}
59+
60+
#include <initializer_list>
61+
template <class T> bool all_of(std::initializer_list<T>);
62+
63+
template <typename... Args> constexpr bool all_of(Args... args) noexcept {
64+
return all_of({args...}); // COMPLIANT - explicitly initialized via varargs
65+
}
66+
67+
void test_all_of() { all_of(true, false, false); }

0 commit comments

Comments
 (0)