From b838b858ed2cfae0d9d3ee655c9285adf5077ea5 Mon Sep 17 00:00:00 2001 From: Kristen Newbury Date: Thu, 25 Jan 2024 13:45:42 -0500 Subject: [PATCH 1/2] M9-3-3: exclude deleted members --- change_notes/2024-01-25-exclusion-m9-3-3.md | 2 ++ cpp/autosar/src/rules/M9-3-3/MemberFunctionConstIfPossible.ql | 3 ++- .../src/rules/M9-3-3/MemberFunctionStaticIfPossible.ql | 3 ++- cpp/autosar/test/rules/M9-3-3/test.cpp | 4 ++++ 4 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 change_notes/2024-01-25-exclusion-m9-3-3.md diff --git a/change_notes/2024-01-25-exclusion-m9-3-3.md b/change_notes/2024-01-25-exclusion-m9-3-3.md new file mode 100644 index 0000000000..7f6d2a339b --- /dev/null +++ b/change_notes/2024-01-25-exclusion-m9-3-3.md @@ -0,0 +1,2 @@ +`M9-3-3`: ` cpp/autosar/member-function-static-if-possible`, `cpp/autosar/member-function-const-if-possible` + - Fixes #413. Exclude deleted member functions. \ No newline at end of file diff --git a/cpp/autosar/src/rules/M9-3-3/MemberFunctionConstIfPossible.ql b/cpp/autosar/src/rules/M9-3-3/MemberFunctionConstIfPossible.ql index 3b0ee9c058..a681f75c5b 100644 --- a/cpp/autosar/src/rules/M9-3-3/MemberFunctionConstIfPossible.ql +++ b/cpp/autosar/src/rules/M9-3-3/MemberFunctionConstIfPossible.ql @@ -121,5 +121,6 @@ where not f.callsNonConstOwnMember() and not f.callsNonConstFromMemberVariable() and not f.isOverride() and - not f.isFinal() + not f.isFinal() and + not f.isDeleted() select f, "Member function can be declared as const." diff --git a/cpp/autosar/src/rules/M9-3-3/MemberFunctionStaticIfPossible.ql b/cpp/autosar/src/rules/M9-3-3/MemberFunctionStaticIfPossible.ql index 36c13fe5d3..5148e72f79 100644 --- a/cpp/autosar/src/rules/M9-3-3/MemberFunctionStaticIfPossible.ql +++ b/cpp/autosar/src/rules/M9-3-3/MemberFunctionStaticIfPossible.ql @@ -39,5 +39,6 @@ from NonStaticMemberFunction nonstatic where not isExcluded(nonstatic, ConstPackage::memberFunctionStaticIfPossibleQuery()) and not exists(ThisExpr t | t.getEnclosingFunction() = nonstatic) and - not nonstatic.isVirtual() + not nonstatic.isVirtual() and + not nonstatic.isDeleted() select nonstatic, "Member function can be declared as static." diff --git a/cpp/autosar/test/rules/M9-3-3/test.cpp b/cpp/autosar/test/rules/M9-3-3/test.cpp index 033414a315..39d61aaccf 100644 --- a/cpp/autosar/test/rules/M9-3-3/test.cpp +++ b/cpp/autosar/test/rules/M9-3-3/test.cpp @@ -161,3 +161,7 @@ class Z22 : Z1 { void f2() final {} // COMPLIANT void f3() { this->a = 100; } // COMPLIANT }; + +class Z3 { + void f(int) = delete; // COMPLIANT +}; \ No newline at end of file From a3eea2221280e42c6e311b0326b9531792cf7538 Mon Sep 17 00:00:00 2001 From: Kristen Newbury Date: Mon, 5 Feb 2024 08:38:28 -0500 Subject: [PATCH 2/2] Update change_notes/2024-01-25-exclusion-m9-3-3.md Co-authored-by: Remco Vermeulen --- change_notes/2024-01-25-exclusion-m9-3-3.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/change_notes/2024-01-25-exclusion-m9-3-3.md b/change_notes/2024-01-25-exclusion-m9-3-3.md index 7f6d2a339b..cb16180172 100644 --- a/change_notes/2024-01-25-exclusion-m9-3-3.md +++ b/change_notes/2024-01-25-exclusion-m9-3-3.md @@ -1,2 +1,2 @@ -`M9-3-3`: ` cpp/autosar/member-function-static-if-possible`, `cpp/autosar/member-function-const-if-possible` +`M9-3-3` - `MemberFunctionConstIfPossible.ql`, `MemberFunctionStaticIfPossible.ql`: - Fixes #413. Exclude deleted member functions. \ No newline at end of file