Ben Clayton cfed1cb01e ast: Tweak cloning rules for module-scope decls
Previously the Clone() of the AST would clone all the functions, globals
and type declarations in a temporary vector, then assign this to the
ast::Module. This meant that adding new module-scope declarations inside
callbacks of ReplaceAll() would place them right at the top, before any
of the cloned declarations.

As top-level declarations are not statements, ensuring that a new object
comes before the current ReplaceAll() declaration is surprisingly
tricky.

With this change, we can now safely assume that calling
ProgramBuilder::Var(), ProgramBuilder::Func(), ProgramBuilder::Alias()
or ProgramBuilder::Structure() inside a ReplaceAll() will add that
module-scoped declaration before the currently processed top-level
declaration.

Change-Id: I52772fdc85940c8ac8d941fbd53374a4dd64a9f4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54320
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-06-16 09:19:36 +00:00
..
2021-05-14 17:51:13 +00:00
2021-06-09 14:32:14 +00:00
2021-04-30 21:27:02 +00:00
2021-05-19 13:25:08 +00:00
2021-03-09 13:52:18 +00:00
2021-03-09 11:11:17 +00:00
2021-03-17 04:55:33 +00:00
2021-05-20 15:10:48 +00:00
2021-06-09 14:32:14 +00:00
2021-03-09 11:11:17 +00:00
2021-06-09 20:17:59 +00:00