Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions score/concurrency/future/base_interruptible_future_test.cpp

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like redundant-move was issued as warning, to remove the redundant moves is legitimate.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/********************************************************************************

Check failure on line 1 in score/concurrency/future/base_interruptible_future_test.cpp

View workflow job for this annotation

GitHub Actions / Restricted file changes

score/concurrency/future/base_interruptible_future_test.cpp is in a restricted path
* Copyright (c) 2025 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
Expand Down Expand Up @@ -316,7 +316,7 @@

BaseInterruptibleFutureTest<TypeParam>::SetPromise(this->promise_);

auto expected = std::move(async_future.get());
auto expected = async_future.get();
EXPECT_TRUE(expected.has_value());
}

Expand Down Expand Up @@ -351,7 +351,7 @@
return this->future_->WaitFor(stop_token, TIMEOUT);
});

auto expected = std::move(async_future.get());
auto expected = async_future.get();
ASSERT_FALSE(expected.has_value());
EXPECT_EQ(expected.error(), Error::kTimeout);
}
Expand Down Expand Up @@ -388,7 +388,7 @@
});
BaseInterruptibleFutureTest<TypeParam>::SetPromise(this->promise_);

auto expected = std::move(async_future.get());
auto expected = async_future.get();
EXPECT_TRUE(expected.has_value());
}

Expand All @@ -400,7 +400,7 @@
return this->future_->WaitUntil(stop_token, std::chrono::steady_clock::now() + TIMEOUT);
});

auto expected = std::move(async_future.get());
auto expected = async_future.get();
ASSERT_FALSE(expected.has_value());
EXPECT_EQ(expected.error(), Error::kTimeout);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/********************************************************************************

Check failure on line 1 in score/concurrency/future/base_interruptible_promise_test.cpp

View workflow job for this annotation

GitHub Actions / Restricted file changes

score/concurrency/future/base_interruptible_promise_test.cpp is in a restricted path
* Copyright (c) 2025 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
Expand Down Expand Up @@ -179,7 +179,8 @@
TYPED_TEST(BaseInterruptiblePromiseTest, MoveAssignmentToSelf)
{
BaseInterruptiblePromise<TypeParam> moved_to_promise{};
moved_to_promise = std::move(moved_to_promise);
auto* promise_ptr = &moved_to_promise;
moved_to_promise = std::move(*promise_ptr);
ASSERT_TRUE(moved_to_promise.GetInterruptibleFuture().has_value());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/********************************************************************************

Check failure on line 1 in score/concurrency/future/interruptible_shared_future_test.cpp

View workflow job for this annotation

GitHub Actions / Restricted file changes

score/concurrency/future/interruptible_shared_future_test.cpp is in a restricted path
* Copyright (c) 2025 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
Expand Down Expand Up @@ -349,7 +349,7 @@

InterruptibleSharedFutureTest<TypeParam>::SetPromise(this->promise_);

auto expected = std::move(async_future.get());
auto expected = async_future.get();
InterruptibleSharedFutureTest<TypeParam>::ExpectCorrectValue(expected);
}

Expand All @@ -358,7 +358,7 @@
this->promise_.SetError(Error::kFutureAlreadyRetrieved);

score::cpp::stop_token stop_token{};
auto expected = std::move(this->future_.Get(stop_token));
auto expected = this->future_.Get(stop_token);
ASSERT_FALSE(expected.has_value());
EXPECT_EQ(expected.error(), Error::kFutureAlreadyRetrieved);
}
Expand Down
2 changes: 1 addition & 1 deletion score/concurrency/task_result_test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/********************************************************************************

Check failure on line 1 in score/concurrency/task_result_test.cpp

View workflow job for this annotation

GitHub Actions / Restricted file changes

score/concurrency/task_result_test.cpp is in a restricted path
* Copyright (c) 2025 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
Expand Down Expand Up @@ -157,7 +157,7 @@
public:
typename T::TaskType Make()
{
return std::move(T::Make(promise_));
return T::Make(promise_);
}

void ExpectCallNTimes(std::uint16_t n)
Expand Down
5 changes: 3 additions & 2 deletions score/containers/dynamic_array_test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/********************************************************************************

Check failure on line 1 in score/containers/dynamic_array_test.cpp

View workflow job for this annotation

GitHub Actions / Restricted file changes

score/containers/dynamic_array_test.cpp is in a restricted path
* Copyright (c) 2025 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
Expand Down Expand Up @@ -263,8 +263,9 @@
DynamicArray<TrivialType, TypeParam> unit{kNonEmptyArraySize,
GetAllocator<TrivialType, TypeParam>(this->memory_resource_)};

// when doing a self-move-assign
unit = std::move(unit);
// when doing a self-move-assign (use pointer indirection to avoid compiler warning)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The self move warnings can be suppressed like this

    DISABLE_WARNING_PUSH
    DISABLE_WARNING_SELF_MOVE

    scope = std::move(scope);

see

@odra odra Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I though it would made more sense to just fix the warnings instead of just ignoring it.

auto* unit_ptr = &unit;
unit = std::move(*unit_ptr);

// expect, that the unit afterward still has the same size
EXPECT_EQ(unit.size(), kNonEmptyArraySize);
Expand Down
12 changes: 8 additions & 4 deletions score/containers/intrusive_list_test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/********************************************************************************

Check failure on line 1 in score/containers/intrusive_list_test.cpp

View workflow job for this annotation

GitHub Actions / Restricted file changes

score/containers/intrusive_list_test.cpp is in a restricted path
* Copyright (c) 2025 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
Expand Down Expand Up @@ -552,7 +552,8 @@
// NOLINTBEGIN(bugprone-use-after-move): testing correctness of implementation

List list;
list = std::move(list);
auto* list_ptr = &list;
list = std::move(*list_ptr);
CheckEmpty(list);

List list_from;
Expand All @@ -562,7 +563,8 @@
list = std::move(list_from);
CheckEmpty(list_from);
CheckNonEmpty(list, 1, front_back, front_back);
list = std::move(list);
list_ptr = &list;
list = std::move(*list_ptr);
CheckNonEmpty(list, 1, front_back, front_back);

ListElement front;
Expand All @@ -572,7 +574,8 @@
list = std::move(list_from);
CheckEmpty(list_from);
CheckNonEmpty(list, 2, front, back);
list = std::move(list);
list_ptr = &list;
list = std::move(*list_ptr);
CheckNonEmpty(list, 2, front, back);

constexpr std::size_t num_elements = 6;
Expand All @@ -581,7 +584,8 @@
list = std::move(list_from);
CheckEmpty(list_from);
CheckNonEmpty(list, num_elements, elements[0], elements[num_elements - 1]);
list = std::move(list);
list_ptr = &list;
list = std::move(*list_ptr);
CheckNonEmpty(list, num_elements, elements[0], elements[num_elements - 1]);
list.clear();

Expand Down
42 changes: 25 additions & 17 deletions score/json/internal/parser/parsers_test_suite.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace
{

template <typename T, std::enable_if_t<!std::is_arithmetic<T>::value, bool> = true>
const T& GetValueOfObject(const score::json::Any& any, const std::string& key)
const T GetValueOfObject(const score::json::Any& any, const std::string& key)
{
return any.As<score::json::Object>().value().get().at(key).As<T>().value().get();
}
Expand Down Expand Up @@ -114,7 +114,7 @@ TYPED_TEST_P(ParserTest, CanParseObjectString)
auto root = TypeParam::FromBuffer(buffer_simple_json);

// When reading a key of an object that is interpreted as std::string
auto& value = GetValueOfObject<std::string>(root.value(), "color");
auto value = GetValueOfObject<std::string>(root.value(), "color");

// Then the correct value is returned
EXPECT_EQ(value, "gold");
Expand All @@ -133,7 +133,7 @@ TYPED_TEST_P(ParserTest, CanParseObjectNull)
auto root = TypeParam::FromBuffer(buffer_simple_json);

// When reading a key of an object that is interpreted as Null
auto& value = GetValueOfObject<Null>(root.value(), "null");
auto value = GetValueOfObject<Null>(root.value(), "null");

// Then the correct value is returned
EXPECT_EQ(value, Null{});
Expand Down Expand Up @@ -172,7 +172,7 @@ TYPED_TEST_P(ParserTest, CanParseObjectFloatingPointNumber)

// When reading a key of an object that is interpreted as floating point number
auto float_value = GetValueOfObject<float>(root.value(), "float");
double double_value = GetValueOfObject<double>(root.value(), "double");
auto double_value = GetValueOfObject<double>(root.value(), "double");
auto double_as_float_value =
root->template As<score::json::Object>().value().get().at("double").template As<float>().has_value();

Expand All @@ -193,14 +193,17 @@ TYPED_TEST_P(ParserTest, CanParseObjectInObject)

// Given a simple JSON buffer
auto root = TypeParam::FromBuffer(buffer_simple_json);

// When reading a key of an object that is interpreted as number
auto& value = GetValueOfObject<Object>(root.value(), "object");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if just removing the & would also work to get rid of the dangling-reference error. Above it seems to work.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It fixed it for primitive types but it required a little bit for objects and lists.


auto value = root.value().template As<Object>().value().get()
.at("object").template As<Object>().value().get()
.at("a").template As<std::string>().value().get();

// Then the correct value is returned
EXPECT_EQ(value.at("a").template As<std::string>().value().get(), "b");
EXPECT_EQ(value, "b");
}


TYPED_TEST_P(ParserTest, CanParseListInObject)
{
this->RecordProperty("Verifies", "5310867");
Expand All @@ -212,14 +215,15 @@ TYPED_TEST_P(ParserTest, CanParseListInObject)

// Given a simple JSON buffer
auto root = TypeParam::FromBuffer(buffer_simple_json);

// When reading a key of an object that is interpreted as number
auto& value = GetValueOfObject<List>(*root, "list");
auto* root_map = &root.value().template As<Object>().value().get();
auto* value = &root_map->at("list").template As<List>().value().get();

// Then the correct value is returned
EXPECT_EQ(value[0].template As<std::string>().value().get(), "first");
EXPECT_EQ(value[1].template As<std::uint64_t>().value(), 2UL);
EXPECT_EQ(value[2].template As<std::string>().value().get(), "third");
EXPECT_EQ((*value)[0].template As<std::string>().value().get(), "first");
EXPECT_EQ((*value)[1].template As<std::uint64_t>().value(), 2UL);
EXPECT_EQ((*value)[2].template As<std::string>().value().get(), "third");
}

TYPED_TEST_P(ParserTest, CanParseObjectInObjectAndIterateOverKeys)
Expand Down Expand Up @@ -257,14 +261,18 @@ TYPED_TEST_P(ParserTest, CanParseObjectInObjectAndIterateOverKeys)
}
)"};
auto root = TypeParam::FromBuffer(buffer);
auto* root_map = &root.value().template As<Object>().value().get();
auto* storage_list = &root_map->at("storage_list").template As<Object>().value().get();

// When iterating over the unknown keys
const auto& storage_list = root.value().template As<Object>().value().get()["storage_list"];
std::vector<std::string> collected_paths{};
for (const auto& element : storage_list.template As<Object>().value().get())
for (const auto& element : *storage_list)
{
auto* inner_obj = &element.second.template As<Object>().value().get();

collected_paths.push_back(
element.second.template As<Object>().value().get().at("path").template As<std::string>().value().get());
inner_obj->at("path").template As<std::string>().value().get()
);
}

// Then we can store them and thus also access them
Expand Down Expand Up @@ -378,7 +386,7 @@ TYPED_TEST_P(ParserTest, ParsingFromFileWorks)
EXPECT_TRUE(root.has_value());

// When reading a key of an object that is interpreted as bool
auto value = GetValueOfObject<bool>(root.value(), "boolean");
bool value = GetValueOfObject<bool>(root.value(), "boolean");

// Then the correct value is returned
EXPECT_EQ(value, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ TEST_F(AllocatorAwareTypeErasurePointerTest, CanMoveAssignSelfWithoutAdverseEffe
DISABLE_WARNING_PUSH
DISABLE_WARNING_SELF_MOVE

target = std::move(target);
auto* target_ptr = &target;
target = std::move(*target_ptr);
Comment on lines +275 to +276

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does the compiler warning look like?
With the DISABLE_WARNING_PUSH above there shouldn't be the need to change this code.


DISABLE_WARNING_POP

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ TEST_F(AllocatorWrapperTest, CorrectlyHandlesSelfMoveAssignment)
DISABLE_WARNING_PUSH
DISABLE_WARNING_SELF_MOVE

allocator_wrapper = std::move(allocator_wrapper);
auto* wrapper_ptr = &allocator_wrapper;
allocator_wrapper = std::move(*wrapper_ptr);

DISABLE_WARNING_POP

Expand Down
3 changes: 2 additions & 1 deletion score/language/safecpp/scoped_function/scope_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ TYPED_TEST(ScopeTest, CanMoveAssignToItselfWithNoAdverseEffects)
DISABLE_WARNING_PUSH
DISABLE_WARNING_SELF_MOVE

scope = std::move(scope);
auto* scope_ptr = &scope;
scope = std::move(*scope_ptr);

DISABLE_WARNING_POP

Expand Down
3 changes: 2 additions & 1 deletion score/memory/shared/lock_file_test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/********************************************************************************

Check failure on line 1 in score/memory/shared/lock_file_test.cpp

View workflow job for this annotation

GitHub Actions / Restricted file changes

score/memory/shared/lock_file_test.cpp is in a restricted path
* Copyright (c) 2025 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
Expand Down Expand Up @@ -554,7 +554,8 @@
ASSERT_TRUE(lock_file_result.has_value());

// When we move assign the lock file to itself
lock_file_result.value() = std::move(lock_file_result.value());
auto* lock_file_ptr = &lock_file_result.value();
lock_file_result.value() = std::move(*lock_file_ptr);

// Then the lock file won't be destroyed
EXPECT_FALSE(close_called);
Expand Down
Loading