Allow ProgramUsage add/remove for any kind of element.
Previously, we only supported adding Statements, although we supported
removing Statements, ProgramElements and Expressions. Now, we can add or
remove any kind of element.
`replace` was deleted; it was only used in one place, and it could be
replaced by a pair of calls to `remove` and `add`. (`replace`
was originally used during the simplification pass.)
Change-Id: I0a0093ab60154fd5f5adfcd5c37d17e576c5379a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/435624
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
diff --git a/src/sksl/SkSLInliner.cpp b/src/sksl/SkSLInliner.cpp
index a668efe..d8f5e27 100644
--- a/src/sksl/SkSLInliner.cpp
+++ b/src/sksl/SkSLInliner.cpp
@@ -1173,7 +1173,8 @@
*enclosingStmt = std::move(inlinedCall.fInlinedBody);
// Replace the candidate function call with our replacement expression.
- usage->replace(candidate.fCandidateExpr->get(), inlinedCall.fReplacementExpr.get());
+ usage->remove(candidate.fCandidateExpr->get());
+ usage->add(inlinedCall.fReplacementExpr.get());
*candidate.fCandidateExpr = std::move(inlinedCall.fReplacementExpr);
madeChanges = true;