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

A15-4-4: Ignore results on uninstantiated templates #416

Merged
merged 2 commits into from
Dec 6, 2023
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
1 change: 1 addition & 0 deletions change_notes/2023-10-26-a15-4-4-noexcept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* `A15-4-4`: remove false positives reported on uninsantiated templates.
6 changes: 4 additions & 2 deletions cpp/autosar/src/rules/A15-4-4/MissingNoExcept.ql
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@ where
// The function is defined in this database
f.hasDefinition() and
// This function is not an overriden call operator of a lambda expression
not exists(LambdaExpression lambda | lambda.getLambdaFunction() = f)
select f, "Function " + f.getName() + " could be declared noexcept(true)."
not exists(LambdaExpression lambda | lambda.getLambdaFunction() = f) and
// Exclude results from uinstantiated templates
not f.isFromUninstantiatedTemplate(_)
select f, "Function " + f.getQualifiedName() + " could be declared noexcept(true)."
13 changes: 13 additions & 0 deletions cpp/autosar/test/rules/A15-4-4/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,17 @@ class A {
void lambda_example() noexcept {
auto with_capture = [=]() {};
auto empty_capture = []() {};
}

#include <utility>
template <typename TypeA, typename TypeB>
void swap_wrapper(TypeA lhs,
TypeB rhs) noexcept(noexcept(std::swap(*lhs, *rhs))) {
std::swap(*lhs, *rhs);
}

void test_swap_wrapper() noexcept {
int a = 0;
int b = 1;
swap_wrapper(&a, &b);
}
Loading