Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions change_notes/2024-01-25-fix-reported-fp-for-a8-4-7.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
`A8-4-7`: ` cpp/autosar/in-parameters-for-cheap-to-copy-types-not-passed-by-value`
- Fixes #397. Exclude user defined operators and move constructors.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import cpp
import codingstandards.cpp.autosar
import TriviallySmallType
import codingstandards.cpp.CommonTypes as CommonTypes
import codingstandards.cpp.Class

/*
* For the purposes of this rule, "cheap to copy" is defined as a trivially copyable type that is no
Expand All @@ -34,7 +35,8 @@ where
) and
t.isConst() and
not exists(CatchBlock cb | cb.getParameter() = v) and
not exists(CopyConstructor cc | cc.getAParameter() = v) and
not exists(SpecialMemberFunction cc | cc.getAParameter() = v) and
not exists(Operator op | op.getAParameter() = v) and
not v.isFromUninstantiatedTemplate(_)
select v,
"Parameter " + v.getName() + " is the trivially copyable type " + t.getName() +
Expand Down
8 changes: 8 additions & 0 deletions cpp/autosar/test/rules/A8-4-7/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,12 @@ inline S1 Value(size_t n, const char *data) {} // COMPLIANT
struct A {
int n;
A(const A &a) : n(a.n) {} // COMPLIANT user-defined copy ctor
A(const A &&other_a); // COMPLIANT user-defined move ctor
};

class C1 {};

class C2 : public C1 {
public:
C2 &operator=(const C2 &); // COMPLIANT
};