Cloning: move arguments to create() into temporary locals
In C++ argument evaluation order is undefined. MSVC and Clang evaluate these in different orders, leading to hilarity when writing tests that expect a deterministic ordering.
Pull out all the argument expressions to create() in the clone functions so a cloned program is deterministic in its ordering between compilers.
Change-Id: I8e2de31398960c480ce7ee1dfaac4f67652d2dbc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41544
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
diff --git a/src/ast/discard_statement.cc b/src/ast/discard_statement.cc
index ec2bf65..9deed12 100644
--- a/src/ast/discard_statement.cc
+++ b/src/ast/discard_statement.cc
@@ -29,7 +29,9 @@
DiscardStatement::~DiscardStatement() = default;
DiscardStatement* DiscardStatement::Clone(CloneContext* ctx) const {
- return ctx->dst->create<DiscardStatement>(ctx->Clone(source()));
+ // Clone arguments outside of create() call to have deterministic ordering
+ auto src = ctx->Clone(source());
+ return ctx->dst->create<DiscardStatement>(src);
}
bool DiscardStatement::IsValid() const {