Skip to content

Commit f462697

Browse files
committed
feat(a14-5-2): do not consider type members declared with using aliases.
1 parent 7736c34 commit f462697

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

cpp/autosar/src/rules/A14-5-2/NonTemplateMemberDefinedInTemplate.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ where
167167
mf = c.getAMemberFunction() and not mf.isCompilerGenerated() and not exists(mf.getBlock())
168168
)
169169
)
170-
)
170+
) and
171+
// Omit using alias (cf. https://github.com/github/codeql-coding-standards/issues/739)
172+
not d instanceof UsingAliasTypedefType
171173
select d,
172174
"Member " + d.getName() + " template class does not use any of template arguments of its $@.",
173175
d.getDeclaringType(), "declaring type"

cpp/autosar/test/rules/A14-5-2/NonTemplateMemberDefinedInTemplate.expected

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
| test.cpp:10:9:10:10 | T1 | Member T1 template class does not use any of template arguments of its $@. | test.cpp:6:29:6:30 | C1<T> | declaring type |
2-
| test.cpp:11:9:11:10 | T2 | Member T2 template class does not use any of template arguments of its $@. | test.cpp:6:29:6:30 | C1<T> | declaring type |
31
| test.cpp:28:31:28:33 | C12<N> | Member C12<N> template class does not use any of template arguments of its $@. | test.cpp:6:29:6:30 | C1<T> | declaring type |
42
| test.cpp:45:7:45:8 | a1 | Member a1 template class does not use any of template arguments of its $@. | test.cpp:37:31:37:33 | C22<N> | declaring type |
53
| test.cpp:46:9:46:10 | a2 | Member a2 template class does not use any of template arguments of its $@. | test.cpp:37:31:37:33 | C22<N> | declaring type |

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ template <typename T> class C1 {
77
public:
88
enum E1 : T { e1, e2 }; // COMPLIANT
99

10-
using T1 = typename template_base<T>::type; // COMPLIANT[FALSE_POSITIVE]
11-
using T2 = typename template_base<int>::type; // NON_COMPLIANT
10+
using T1 = typename template_base<T>::type; // COMPLIANT
11+
using T2 = typename template_base<int>::type; // NON_COMPLIANT[FALSE_NEGATIVE]
1212

1313
class C11 { // COMPLIANT
1414
enum E2 {
@@ -156,4 +156,4 @@ template <J::Type t> class V {
156156
void f4() {
157157
V<J::Type::A> v;
158158
v.type();
159-
}
159+
}

0 commit comments

Comments
 (0)