Skip to content

Commit f99713a

Browse files
committed
A8-4-7: exclude user defined operators and move constructors
1 parent 1c4c483 commit f99713a

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
`A8-4-7`: ` cpp/autosar/in-parameters-for-cheap-to-copy-types-not-passed-by-value`
2+
- Fixes #397. Exclude user defined operators and move constructors.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ where
3535
t.isConst() and
3636
not exists(CatchBlock cb | cb.getParameter() = v) and
3737
not exists(CopyConstructor cc | cc.getAParameter() = v) and
38+
not exists(MoveConstructor mc | mc.getAParameter() = v) and
39+
not exists(Operator op | op.getAParameter() = v) and
3840
not v.isFromUninstantiatedTemplate(_)
3941
select v,
4042
"Parameter " + v.getName() + " is the trivially copyable type " + t.getName() +

cpp/autosar/test/rules/A8-4-7/test.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,12 @@ inline S1 Value(size_t n, const char *data) {} // COMPLIANT
3737
struct A {
3838
int n;
3939
A(const A &a) : n(a.n) {} // COMPLIANT user-defined copy ctor
40+
A(const A &&other_a); // COMPLIANT user-defined move ctor
4041
};
42+
43+
class C1 {};
44+
45+
class C2 : public C1 {
46+
public:
47+
C2 &operator=(const C2 &); // COMPLIANT
48+
};

0 commit comments

Comments
 (0)