Skip to content

Commit a82b0ff

Browse files
Merge remote-tracking branch 'origin/main' into michaelrfairhurst/preconditions5-only-std-move-lvalues
2 parents 35010f0 + 68892e6 commit a82b0ff

File tree

113 files changed

+3523
-98
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+3523
-98
lines changed
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
// GENERATED FILE - DO NOT MODIFY
22
import codingstandards.cpp.rules.unusedparameter.UnusedParameter
33

4-
class TestFileQuery extends UnusedParameterSharedQuery, TestQuery { }
4+
module UnusedParameterTestConfig implements UnusedParameterSharedConfigSig {
5+
Query getQuery() { result instanceof TestQuery }
6+
}
7+
8+
import UnusedParameterShared<UnusedParameterTestConfig>

c/common/test/rules/unusedtypedeclarations/UnusedTypeDeclarations.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
| test.c:7:18:7:18 | D | Type declaration D is not used. |
33
| test.c:28:11:28:11 | R | Type declaration R is not used. |
44
| test.c:41:12:41:12 | (unnamed class/struct/union) | Type declaration (unnamed class/struct/union) is not used. |
5+
| test.c:56:3:56:4 | T2 | Type declaration T2 is not used. |

c/common/test/rules/unusedtypedeclarations/test.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,13 @@ void test_nested_struct() {
4949
s.f1;
5050
s.f3;
5151
s.f5;
52-
}
52+
}
53+
54+
typedef struct {
55+
int m1;
56+
} T2; // NON_COMPLIANT
57+
typedef struct {
58+
int m1;
59+
} T1; // COMPLIANT - used in function below
60+
61+
void test_typedef() { T1 t1; }

c/misra/src/rules/RULE-2-7/UnusedParameter.ql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import cpp
1616
import codingstandards.c.misra
1717
import codingstandards.cpp.rules.unusedparameter.UnusedParameter
1818

19-
class UnusedParameterQuery extends UnusedParameterSharedQuery {
20-
UnusedParameterQuery() { this = DeadCodePackage::unusedParameterQuery() }
19+
module UnusedParameterQueryConfig implements UnusedParameterSharedConfigSig {
20+
Query getQuery() { result = DeadCodePackage::unusedParameterQuery() }
2121
}
22+
23+
import UnusedParameterShared<UnusedParameterQueryConfig>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- `A0-1-4`, `RULE-2-7` - `UnusedParameter.ql`:
2+
- Refactored to be able to share most logic between MISRA C, MISRA C++, and AUTOSAR. No visible change in behavior expected.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
- `RULE-2-3`, `A0-1-6` - `UnusedTypeDeclarations.ql`:
2+
- Type usage analysis has been improved to find more possible type usages, including:
3+
- Previous behavior considered anonymous types in variable declarations to be considered used by the variable definition itself. This has been improved to require that a field of the anonymous type is accessed for the type to be considered used.
4+
- Usages of a template type inside a specialization of that template are no longer considered usages of the template type.
5+
- Hidden friend declarations are no longer considered usages of the class they are declaring friendship for.
6+
- Improved exclusions generally, for cases such as nested types and functions within functions. These previously were a source of incorrectly identified type uses.
7+
- Additional case added to detect `template <Enum = Enum::Value>` as a usage of `Enum`, without an explicit `tpl<Enum::Value>` usage.

cpp/autosar/src/rules/A0-1-4/UnusedParameter.ql

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ import codingstandards.cpp.autosar
1818
import codingstandards.cpp.deadcode.UnusedParameters
1919
import codingstandards.cpp.rules.unusedparameter.UnusedParameter
2020

21-
class UnusedParameterQuery extends UnusedParameterSharedQuery {
22-
UnusedParameterQuery() { this = DeadCodePackage::unusedParameterQuery() }
21+
module UnusedParameterQueryConfig implements UnusedParameterSharedConfigSig {
22+
Query getQuery() { result = DeadCodePackage::unusedParameterQuery() }
23+
24+
predicate excludeParameter(Parameter p) {
25+
// Virtual functions are covered by a different rule
26+
p.getFunction().isVirtual()
27+
}
2328
}
29+
30+
import UnusedParameterShared<UnusedParameterQueryConfig>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| test.cpp:2:14:2:14 | x | Unused parameter 'x' for function $@. | test.cpp:2:8:2:8 | b | A::b |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rules/A0-1-4/UnusedParameter.ql

cpp/autosar/test/rules/A0-1-4/UnusedParameter.testref

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)