From: Arnaud Giersch Date: Thu, 29 Jun 2023 07:32:33 +0000 (+0200) Subject: The result of "std::move" should not be passed as a const reference (Sonar). X-Git-Tag: v3.35~169 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/7cf8d7e8f6c14b423e56e790adbfe695cca9ee51 The result of "std::move" should not be passed as a const reference (Sonar). --- diff --git a/src/mc/explo/udpor/Configuration.cpp b/src/mc/explo/udpor/Configuration.cpp index 600a4f7e73..2dd00cb265 100644 --- a/src/mc/explo/udpor/Configuration.cpp +++ b/src/mc/explo/udpor/Configuration.cpp @@ -213,7 +213,7 @@ std::optional Configuration::compute_k_partial_alternative_to(con for (const auto& event_in_spike : spikes) { events.push_back(*event_in_spike); } - return EventSet(std::move(events)); + return EventSet(events); }; const auto alternative = std::find_if(comb.combinations_begin(), comb.combinations_end(), diff --git a/src/mc/explo/udpor/Configuration_test.cpp b/src/mc/explo/udpor/Configuration_test.cpp index 0105b0b29a..a20f38214d 100644 --- a/src/mc/explo/udpor/Configuration_test.cpp +++ b/src/mc/explo/udpor/Configuration_test.cpp @@ -377,15 +377,13 @@ TEST_CASE("simgrid::mc::udpor::Configuration: Topological Sort Order Very Compli SECTION("Forward direction") { - auto ordered_events = C.get_topologically_sorted_events(); - const auto ordered_event_set = EventSet(std::move(ordered_events)); + const auto ordered_event_set = EventSet(C.get_topologically_sorted_events()); REQUIRE(events_seen == ordered_event_set); } SECTION("Reverse direction") { - auto ordered_events = C.get_topologically_sorted_events_of_reverse_graph(); - const auto ordered_event_set = EventSet(std::move(ordered_events)); + const auto ordered_event_set = EventSet(C.get_topologically_sorted_events_of_reverse_graph()); REQUIRE(events_seen == ordered_event_set); } } diff --git a/src/mc/explo/udpor/EventSet_test.cpp b/src/mc/explo/udpor/EventSet_test.cpp index afe4ea569b..4c8287ccb2 100644 --- a/src/mc/explo/udpor/EventSet_test.cpp +++ b/src/mc/explo/udpor/EventSet_test.cpp @@ -770,15 +770,15 @@ TEST_CASE("simgrid::mc::udpor::EventSet: Moving into a collection") EventSet C_copy = C; EventSet D_copy = D; - std::vector actual_A = std::move(A).move_into_vector(); - std::vector actual_B = std::move(B).move_into_vector(); - std::vector actual_C = std::move(C).move_into_vector(); - std::vector actual_D = std::move(D).move_into_vector(); - - EventSet A_copy_remade(std::move(actual_A)); - EventSet B_copy_remade(std::move(actual_B)); - EventSet C_copy_remade(std::move(actual_C)); - EventSet D_copy_remade(std::move(actual_D)); + const std::vector actual_A = std::move(A).move_into_vector(); + const std::vector actual_B = std::move(B).move_into_vector(); + const std::vector actual_C = std::move(C).move_into_vector(); + const std::vector actual_D = std::move(D).move_into_vector(); + + EventSet A_copy_remade(actual_A); + EventSet B_copy_remade(actual_B); + EventSet C_copy_remade(actual_C); + EventSet D_copy_remade(actual_D); REQUIRE(A_copy == A_copy_remade); REQUIRE(B_copy == B_copy_remade); diff --git a/src/mc/explo/udpor/ExtensionSetCalculator.cpp b/src/mc/explo/udpor/ExtensionSetCalculator.cpp index 6456fff676..11c9ae8751 100644 --- a/src/mc/explo/udpor/ExtensionSetCalculator.cpp +++ b/src/mc/explo/udpor/ExtensionSetCalculator.cpp @@ -53,7 +53,7 @@ EventSet ExtensionSetCalculator::partially_extend_CommSend(const Configuration& { EventSet exC; - const auto send_action = std::static_pointer_cast(std::move(action)); + const auto send_action = std::static_pointer_cast(action); const auto pre_event_a_C = C.pre_event(send_action->aid_); const unsigned sender_mailbox = send_action->get_mailbox(); @@ -95,7 +95,7 @@ EventSet ExtensionSetCalculator::partially_extend_CommRecv(const Configuration& { EventSet exC; - const auto recv_action = std::static_pointer_cast(std::move(action)); + const auto recv_action = std::static_pointer_cast(action); const unsigned recv_mailbox = recv_action->get_mailbox(); const auto pre_event_a_C = C.pre_event(recv_action->aid_); @@ -301,7 +301,7 @@ EventSet ExtensionSetCalculator::partially_extend_CommWait(const Configuration& // `WaitAny()` is always disabled in `config(K)`; hence, it // is independent of any transition in `config(K)` (according // to formal definition of independence) - const auto K = EventSet({e, pre_event_a_C.value_or(e)}); + auto K = EventSet({e, pre_event_a_C.value_or(e)}); const auto config_K = History(K); if (not config_K.contains(e_issuer)) { continue;