Skip to content

Commit

Permalink
Merge pull request #746 from fjatWbyT/feat-type-member-alias-a14-5-2
Browse files Browse the repository at this point in the history
`A14-5-2` do not consider type members declared with using aliases.
  • Loading branch information
lcartey authored Oct 16, 2024
2 parents 20a3711 + fbfdcae commit b476450
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions change_notes/2024-10-15-fix-fp-739-a14-5-2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `A14-5-2` - `NonTemplateMemberDefinedInTemplate.ql`
- Fixes #739. Correctly detect template parameters specified in using alias base types, e.g. `using T1 = some_type<T>::Type;`.
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,10 @@ where
mf = c.getAMemberFunction() and not mf.isCompilerGenerated() and not exists(mf.getBlock())
)
)
)
) and
// Omit using alias (cf. https://github.com/github/codeql-coding-standards/issues/739)
// Exclude Using alias which refer directly to a TypeParameter
not d.(UsingAliasTypedefType).getBaseType() instanceof TemplateParameter
select d,
"Member " + d.getName() + " template class does not use any of template arguments of its $@.",
d.getDeclaringType(), "declaring type"
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
| 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 |
| 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 |
| 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 |
| 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 |
Expand Down
4 changes: 2 additions & 2 deletions cpp/autosar/test/rules/A14-5-2/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ template <typename T> class C1 {
public:
enum E1 : T { e1, e2 }; // COMPLIANT

using T1 = typename template_base<T>::type; // COMPLIANT[FALSE_POSITIVE]
using T1 = typename template_base<T>::type; // COMPLIANT
using T2 = typename template_base<int>::type; // NON_COMPLIANT

class C11 { // COMPLIANT
Expand Down Expand Up @@ -156,4 +156,4 @@ template <J::Type t> class V {
void f4() {
V<J::Type::A> v;
v.type();
}
}

0 comments on commit b476450

Please sign in to comment.