Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A14-5-2 do not consider type members declared with using aliases. #746

Merged
merged 7 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
}
Loading