Skip to content

Commit 52a4275

Browse files
author
Nikita Kraiouchkine
authored
Merge pull request #416 from github/lcartey/a15-4-4-fix-noexcept
`A15-4-4`: Ignore results on uninstantiated templates
2 parents d74222a + cba155c commit 52a4275

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* `A15-4-4`: remove false positives reported on uninsantiated templates.

cpp/autosar/src/rules/A15-4-4/MissingNoExcept.ql

+4-2
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,7 @@ where
3333
// The function is defined in this database
3434
f.hasDefinition() and
3535
// This function is not an overriden call operator of a lambda expression
36-
not exists(LambdaExpression lambda | lambda.getLambdaFunction() = f)
37-
select f, "Function " + f.getName() + " could be declared noexcept(true)."
36+
not exists(LambdaExpression lambda | lambda.getLambdaFunction() = f) and
37+
// Exclude results from uinstantiated templates
38+
not f.isFromUninstantiatedTemplate(_)
39+
select f, "Function " + f.getQualifiedName() + " could be declared noexcept(true)."

cpp/autosar/test/rules/A15-4-4/test.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,17 @@ class A {
3030
void lambda_example() noexcept {
3131
auto with_capture = [=]() {};
3232
auto empty_capture = []() {};
33+
}
34+
35+
#include <utility>
36+
template <typename TypeA, typename TypeB>
37+
void swap_wrapper(TypeA lhs,
38+
TypeB rhs) noexcept(noexcept(std::swap(*lhs, *rhs))) {
39+
std::swap(*lhs, *rhs);
40+
}
41+
42+
void test_swap_wrapper() noexcept {
43+
int a = 0;
44+
int b = 1;
45+
swap_wrapper(&a, &b);
3346
}

0 commit comments

Comments
 (0)