Add Type::isVoid and make void a distinct type-kind.
This makes it easier and faster to check for void types, especially
when you don't have a Context.
`Type::isOpaque` would previously return true for void, and this CL
preserves that behavior to avoid changing the meaning of existing code.
Change-Id: I6e1699dd8daee4c5fa8cf4746bab84c1d3fc15d0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/385499
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/src/sksl/SkSLInliner.cpp b/src/sksl/SkSLInliner.cpp
index 90c5fad..5151abc 100644
--- a/src/sksl/SkSLInliner.cpp
+++ b/src/sksl/SkSLInliner.cpp
@@ -644,7 +644,7 @@
std::unique_ptr<Expression> resultExpr;
if (returnComplexity > ReturnComplexity::kSingleSafeReturn &&
- function.declaration().returnType() != *fContext->fTypes.fVoid) {
+ !function.declaration().returnType().isVoid()) {
// Create a variable to hold the result in the extra statements. We don't need to do this
// for void-return functions, or in cases that are simple enough that we can just replace
// the function-call node with the result expression.
@@ -761,7 +761,7 @@
if (resultExpr) {
// Return our result expression as-is.
inlinedCall.fReplacementExpr = std::move(resultExpr);
- } else if (function.declaration().returnType() == *fContext->fTypes.fVoid) {
+ } else if (function.declaration().returnType().isVoid()) {
// It's a void function, so it doesn't actually result in anything, but we have to return
// something non-null as a standin.
inlinedCall.fReplacementExpr = BoolLiteral::Make(*fContext, offset, /*value=*/false);