ast: Fix double type decl bug
If during clone, we register a type, function or global declaration, we could end up with the declaration held twice by the AST Module. AST nodes must only be referenced once. Change-Id: I5c517699ea80422800639088b97a50ba9ac27b70 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55245 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
parent
c3dc300fcb
commit
9efc4fcc89
|
@ -89,6 +89,13 @@ Module* Module::Clone(CloneContext* ctx) const {
|
||||||
|
|
||||||
void Module::Copy(CloneContext* ctx, const Module* src) {
|
void Module::Copy(CloneContext* ctx, const Module* src) {
|
||||||
ctx->Clone(global_declarations_, src->global_declarations_);
|
ctx->Clone(global_declarations_, src->global_declarations_);
|
||||||
|
|
||||||
|
// During the clone, declarations may have been placed into the module.
|
||||||
|
// Clear everything out, as we're about to re-bin the declarations.
|
||||||
|
type_decls_.clear();
|
||||||
|
functions_.clear();
|
||||||
|
global_variables_.clear();
|
||||||
|
|
||||||
for (auto* decl : global_declarations_) {
|
for (auto* decl : global_declarations_) {
|
||||||
if (!decl) {
|
if (!decl) {
|
||||||
TINT_ICE(ctx->dst->Diagnostics()) << "src global declaration was nullptr";
|
TINT_ICE(ctx->dst->Diagnostics()) << "src global declaration was nullptr";
|
||||||
|
|
Loading…
Reference in New Issue