From 051607368e8d3dd55d2ad2b2200ef656244ec70d Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 17 Feb 2023 13:23:27 -0800 Subject: Fixed crash when lowering IR for no_diff struct member. (#2658) * Fixed crash when lowering IR for no_diff struct member. * Improve `setInsertBeforeOrdinaryInst` and `setInsertAfterOrdinaryInst`. --------- Co-authored-by: Yong He --- source/slang/slang-lower-to-ir.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source/slang/slang-lower-to-ir.cpp') diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index f78dd39e5..aa2dc4efb 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -3320,6 +3320,7 @@ struct ExprLoweringVisitorBase : ExprVisitor LoweredValInfo getSimpleDefaultVal(IRType* type) { + type = (IRType*)unwrapAttributedType(type); if(auto basicType = as(type)) { switch( basicType->getBaseType() ) @@ -3355,8 +3356,18 @@ struct ExprLoweringVisitorBase : ExprVisitor UNREACHABLE_RETURN(LoweredValInfo()); } + Type* getOriginalTypeFromModifiedType(Type* type) + { + auto innerType = type; + while (auto modifiedType = as(innerType)) + innerType = modifiedType->base; + return innerType; + } + LoweredValInfo getDefaultVal(Type* type) { + type = getOriginalTypeFromModifiedType(type); + auto irType = lowerType(context, type); if (auto basicType = as(type)) { @@ -7909,6 +7920,7 @@ struct DeclLoweringVisitor : DeclVisitor bool isClassType(IRType* type) { + type = (IRType*)unwrapAttributedType(type); if (auto specialize = as(type)) { return findSpecializeReturnVal(specialize)->getOp() == kIROp_ClassType; -- cgit v1.2.3