Reuse moved-from tint::Program variables
Currently, it's impossible to move a tint::Program instance into a variables that has been moved. This CL fixes that. Bug: tint:1105 Change-Id: Idc04cf2bb569d1cffc2c309117fc4615c41ac76a Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61640 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
This commit is contained in:
parent
5085efb748
commit
9e3e54b932
|
@ -83,6 +83,7 @@ Program::~Program() = default;
|
|||
Program& Program::operator=(Program&& program) {
|
||||
program.AssertNotMoved();
|
||||
program.moved_ = true;
|
||||
moved_ = false;
|
||||
id_ = std::move(program.id_);
|
||||
types_ = std::move(program.types_);
|
||||
ast_nodes_ = std::move(program.ast_nodes_);
|
||||
|
|
|
@ -102,5 +102,16 @@ TEST_F(ProgramTest, DiagnosticsMove) {
|
|||
EXPECT_EQ(program_b.Diagnostics().begin()->message, "an error message");
|
||||
}
|
||||
|
||||
TEST_F(ProgramTest, ReuseMovedFromVariable) {
|
||||
Program a(std::move(*this));
|
||||
EXPECT_TRUE(a.IsValid());
|
||||
|
||||
Program b = std::move(a);
|
||||
EXPECT_TRUE(b.IsValid());
|
||||
|
||||
a = std::move(b);
|
||||
EXPECT_TRUE(a.IsValid());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace tint
|
||||
|
|
Loading…
Reference in New Issue