CloneContext: Remove remnants of clone pointer de-duping

It appears that I didn't do a great job cleaning up the removal of ShareableCloneable in https://dawn-review.googlesource.com/c/tint/+/51484.

Cloning nodes shouldn't return the same pointer. Remove bad comments.
Clean up leftover logic from CloneWithoutTransform().

Change-Id: Ibbc5f625c5978e9c11da59e7aa6197f39b6f0363
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/58220
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton 2021-07-15 16:37:24 +00:00 committed by Tint LUCI CQ
parent ff3dbc361b
commit 487a913e31
1 changed files with 2 additions and 18 deletions

View File

@ -85,9 +85,7 @@ class CloneContext {
~CloneContext(); ~CloneContext();
/// Clones the Node or sem::Type `a` into the ProgramBuilder #dst if `a` is /// Clones the Node or sem::Type `a` into the ProgramBuilder #dst if `a` is
/// not null. If `a` is null, then Clone() returns null. If `a` has been /// not null. If `a` is null, then Clone() returns null.
/// cloned already by this CloneContext then the same cloned pointer is
/// returned.
/// ///
/// Clone() may use a function registered with ReplaceAll() to create a /// Clone() may use a function registered with ReplaceAll() to create a
/// transformed version of the object. See ReplaceAll() for more information. /// transformed version of the object. See ReplaceAll() for more information.
@ -140,9 +138,7 @@ class CloneContext {
} }
/// Clones the Node or sem::Type `a` into the ProgramBuilder #dst if `a` is /// Clones the Node or sem::Type `a` into the ProgramBuilder #dst if `a` is
/// not null. If `a` is null, then Clone() returns null. If `a` has been /// not null. If `a` is null, then Clone() returns null.
/// cloned already by this CloneContext then the same cloned pointer is
/// returned.
/// ///
/// Unlike Clone(), this method does not invoke or use any transformations /// Unlike Clone(), this method does not invoke or use any transformations
/// registered by ReplaceAll(). /// registered by ReplaceAll().
@ -158,22 +154,10 @@ class CloneContext {
if (a == nullptr) { if (a == nullptr) {
return nullptr; return nullptr;
} }
if (src) { if (src) {
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(Clone, src, a); TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(Clone, src, a);
} }
// Have we seen this object before? If so, return the previously cloned
// version instead of making yet another copy.
auto it = replacements_.find(a);
if (it != replacements_.end()) {
return CheckedCast<T>(it->second);
}
// First time clone and no replacer transforms matched.
// Clone with T::Clone().
auto* c = a->Clone(this); auto* c = a->Clone(this);
replacements_.emplace(a, c);
return CheckedCast<T>(c); return CheckedCast<T>(c);
} }