Fix TypesBuilder::builder pointer initialization
When copying or moving a ProgramBuilder, we always want the ProgramBuilder::ty to point back to the owner. We were previously std::move()'ing the ty field, which is not correct - this will result in the TypesBuilder pointing to the wrong ProgramBuilder. I'm not sure why we've not seen any issues with this using clang, but running under MSVC immediately highlighted this brokenness. Change-Id: I4293bb00ac4fbdfa66d12b1504a7bd060e014cd6 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41861 Commit-Queue: Ben Clayton <bclayton@google.com> Auto-Submit: Ben Clayton <bclayton@google.com> Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
34ae7d2ce7
commit
c7ca7668cc
|
@ -28,11 +28,10 @@
|
|||
namespace tint {
|
||||
|
||||
ProgramBuilder::ProgramBuilder()
|
||||
: ty(this), ast_(ast_nodes_.Create<ast::Module>(Source{})) {}
|
||||
: ast_(ast_nodes_.Create<ast::Module>(Source{})) {}
|
||||
|
||||
ProgramBuilder::ProgramBuilder(ProgramBuilder&& rhs)
|
||||
: ty(std::move(rhs.ty)),
|
||||
types_(std::move(rhs.types_)),
|
||||
: types_(std::move(rhs.types_)),
|
||||
ast_nodes_(std::move(rhs.ast_nodes_)),
|
||||
sem_nodes_(std::move(rhs.sem_nodes_)),
|
||||
ast_(rhs.ast_),
|
||||
|
@ -46,7 +45,6 @@ ProgramBuilder::~ProgramBuilder() = default;
|
|||
ProgramBuilder& ProgramBuilder::operator=(ProgramBuilder&& rhs) {
|
||||
rhs.MarkAsMoved();
|
||||
AssertNotMoved();
|
||||
ty = std::move(rhs.ty);
|
||||
types_ = std::move(rhs.types_);
|
||||
ast_nodes_ = std::move(rhs.ast_nodes_);
|
||||
sem_nodes_ = std::move(rhs.sem_nodes_);
|
||||
|
|
|
@ -477,7 +477,7 @@ class ProgramBuilder {
|
|||
template <typename T>
|
||||
struct CToAST {};
|
||||
|
||||
ProgramBuilder* builder;
|
||||
ProgramBuilder* const builder;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1101,7 +1101,7 @@ class ProgramBuilder {
|
|||
void WrapInFunction(ast::StatementList stmts);
|
||||
|
||||
/// The builder types
|
||||
TypesBuilder ty;
|
||||
TypesBuilder const ty{this};
|
||||
|
||||
protected:
|
||||
/// Asserts that the builder has not been moved.
|
||||
|
|
Loading…
Reference in New Issue