Skip to content

Commit 898c7f1

Browse files
committed
A8-4-7: exclusion for templates
1 parent cdde1f3 commit 898c7f1

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
`A8-4-7`: `InParametersForCheapToCopyTypesNotPassedByValue.ql`
2-
- Fixes #397. Exclude user defined operators and move constructors.`
1+
`A8-4-7`: `InParametersForCheapToCopyTypesNotPassedByValue.ql`, `InParametersForNotCheapToCopyTypesNotPassedByReference.ql`
2+
- Fixes #397. Exclude user defined operators and move constructors.`
3+
- Exclude parameters for instantiated templates because the declaration location of the function does not contain enough information about the type used in the instantiation to make an actionable alert.

cpp/autosar/src/rules/A8-4-7/InParametersForCheapToCopyTypesNotPassedByValue.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ where
3737
not exists(CatchBlock cb | cb.getParameter() = v) and
3838
not exists(SpecialMemberFunction cc | cc.getAParameter() = v) and
3939
not exists(Operator op | op.getAParameter() = v) and
40-
not v.isFromUninstantiatedTemplate(_)
40+
not v.isFromUninstantiatedTemplate(_) and
41+
not v.isFromTemplateInstantiation(_)
4142
select v,
4243
"Parameter '" + v.getName() + "' is the trivially copyable type '" + t.getName() +
4344
"' but it is passed by reference instead of by value."

cpp/autosar/src/rules/A8-4-7/InParametersForNotCheapToCopyTypesNotPassedByReference.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ where
3131
not v.getType() instanceof TriviallySmallType and
3232
not v.getType().getUnderlyingType() instanceof ReferenceType and
3333
not exists(CatchBlock cb | cb.getParameter() = v) and
34-
not v.isFromUninstantiatedTemplate(_)
34+
not v.isFromUninstantiatedTemplate(_) and
35+
not v.isFromTemplateInstantiation(_)
3536
select v,
3637
"Parameter " + v.getName() +
3738
" is the trivially non-copyable type $@ but it is passed by value instead of by reference.",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| test.cpp:20:19:20:21 | f5a | Parameter f5a is the trivially copyable type const S1 but it is passed by reference instead of by value. |
1+
| test.cpp:20:19:20:21 | f5a | Parameter 'f5a' is the trivially copyable type 'const S1' but it is passed by reference instead of by value. |

0 commit comments

Comments
 (0)