summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2021-04-05 13:40:45 -0700
committerGitHub <noreply@github.com>2021-04-05 16:40:45 -0400
commit95a61ab5e49134e87584ca302b90bd78a5a58864 (patch)
tree65a0696befb51f78953092adc3a2cc4d182d70ba /source
parent086ecf41fa21138899960bb9805bc8ced91690f0 (diff)
Fix a bug in the "operator cache" (#1784)
In order to speed up compilation, the semantic checking step uses a cache for overload resolution in the case of an operator being applied to operations of basic scalar types and vectors/matrices thereof. The logic for construct keys for that cache was defensive against the case of, e.g., `vector<int,N>` where the element count `N` of the vector was not a literal value but a generic parameter. For some reason it did not have equivalent safeguards for a case like `vector<T,2>` where the element type was not a basic type, and it would instead assume all vector/matrix types had basic types as their element type. This change fixes the logic to make it properly defensive against this case. Co-authored-by: jsmall-nvidia <jsmall@nvidia.com>
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-check-impl.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/source/slang/slang-check-impl.h b/source/slang/slang-check-impl.h
index bc265b1b4..623f18b22 100644
--- a/source/slang/slang-check-impl.h
+++ b/source/slang/slang-check-impl.h
@@ -44,8 +44,10 @@ namespace Slang
{
if (auto elemCount = as<ConstantIntVal>(vectorType->elementCount))
{
- auto elemBasicType = as<BasicExpressionType>(vectorType->elementType);
- return makeBasicTypeKey(elemBasicType->baseType, elemCount->value);
+ if( auto elemBasicType = as<BasicExpressionType>(vectorType->elementType) )
+ {
+ return makeBasicTypeKey(elemBasicType->baseType, elemCount->value);
+ }
}
}
else if (auto matrixType = as<MatrixExpressionType>(typeIn))
@@ -54,8 +56,10 @@ namespace Slang
{
if (auto elemCount2 = as<ConstantIntVal>(matrixType->getColumnCount()))
{
- auto elemBasicType = as<BasicExpressionType>(matrixType->getElementType());
- return makeBasicTypeKey(elemBasicType->baseType, elemCount1->value, elemCount2->value);
+ if( auto elemBasicType = as<BasicExpressionType>(matrixType->getElementType()) )
+ {
+ return makeBasicTypeKey(elemBasicType->baseType, elemCount1->value, elemCount2->value);
+ }
}
}
}