Skip to content

Commit efe6b63

Browse files
authored
Merge pull request #348 from rak3-sh/rp/a5-1-3-false-positives-fix
Fix for A5-1-3 false positives
2 parents 9c7da19 + 4297f0a commit efe6b63

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- `A5-1-3` - Only consider lambdas that have zero arguments, since any lambda with non-zero arguments will have an explicit argument list.

cpp/autosar/src/rules/A5-1-3/LambdaExpressionWithoutParameterList.ql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ where
2121
not isExcluded(lambda, LambdasPackage::lambdaExpressionWithoutParameterListQuery()) and
2222
lambdaFunction = lambda.getLambdaFunction() and
2323
not lambdaFunction.isAffectedByMacro() and
24+
// If it has a parameter, then it will have an
25+
// explicit parameter list. Therefore, proceed to check only if the lambda
26+
// does not have any parameters.
27+
not exists (lambdaFunction.getAParameter()) and
2428
// The extractor doesn't store the syntactic information whether the parameter list
2529
// is enclosed in parenthesis. Therefore we cannot determine if the parameter list is
2630
// explicitly specified when the parameter list is empty.

cpp/autosar/test/rules/A5-1-3/test.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,11 @@ void test() {
2828
l1 += 1;
2929
};
3030
// clang-format on
31-
}
31+
}
32+
33+
#define PARAM_MACRO [](int i) { i; };
34+
35+
int test_lambda_in_macro() {
36+
PARAM_MACRO // COMPLIANT
37+
return 0;
38+
}

0 commit comments

Comments
 (0)