diff options
Diffstat (limited to 'source/slang')
| -rw-r--r-- | source/slang/bytecode.cpp | 8 | ||||
| -rw-r--r-- | source/slang/check.cpp | 6 | ||||
| -rw-r--r-- | source/slang/emit.cpp | 4 | ||||
| -rw-r--r-- | source/slang/ir.cpp | 10 | ||||
| -rw-r--r-- | source/slang/lower-to-ir.cpp | 25 | ||||
| -rw-r--r-- | source/slang/lower.cpp | 4 | ||||
| -rw-r--r-- | source/slang/parameter-binding.cpp | 4 | ||||
| -rw-r--r-- | source/slang/syntax.cpp | 10 | ||||
| -rw-r--r-- | source/slang/type-layout.cpp | 10 | ||||
| -rw-r--r-- | source/slang/vm.cpp | 6 |
10 files changed, 44 insertions, 43 deletions
diff --git a/source/slang/bytecode.cpp b/source/slang/bytecode.cpp index f1b23849d..ed969b72d 100644 --- a/source/slang/bytecode.cpp +++ b/source/slang/bytecode.cpp @@ -271,9 +271,9 @@ BCConst getGlobalValue( } SLANG_UNEXPECTED("no ID for inst"); - bcConst.flavor = (BCConstFlavor) -1; - bcConst.id = -9999; - return bcConst; + UNREACHABLE(bcConst.flavor = (BCConstFlavor) -1); + UNREACHABLE(bcConst.id = -9999); + UNREACHABLE_RETURN(bcConst); } Int getLocalID( @@ -577,7 +577,7 @@ BytecodeGenerationPtr<BCType> emitBCTypeImpl( SLANG_UNEXPECTED("unimplemented"); - return BytecodeGenerationPtr<BCType>(); + UNREACHABLE_RETURN(BytecodeGenerationPtr<BCType>()); } BytecodeGenerationPtr<BCType> emitBCType( diff --git a/source/slang/check.cpp b/source/slang/check.cpp index 0c35c4bf4..dbbd8f283 100644 --- a/source/slang/check.cpp +++ b/source/slang/check.cpp @@ -3328,7 +3328,7 @@ namespace Slang // to `interfaceDeclRef`. // SLANG_UNEXPECTED("reflexive type witness"); - return nullptr; + UNREACHABLE_RETURN(nullptr); } auto breadcrumbs = inBreadcrumbs; @@ -3343,7 +3343,7 @@ namespace Slang // because `A : B` and `B : C` then `A : C` // SLANG_UNEXPECTED("transitive type witness"); - return nullptr; + UNREACHABLE_RETURN(nullptr); } // Simple case: we have a single declaration @@ -5947,7 +5947,7 @@ namespace Slang RefPtr<Expr> visitStaticMemberExpr(StaticMemberExpr* expr) { SLANG_UNEXPECTED("should not occur in unchecked AST"); - return expr; + UNREACHABLE_RETURN(expr); } RefPtr<Expr> lookupResultFailure( diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp index 2e8ab58d4..af4f0ad6a 100644 --- a/source/slang/emit.cpp +++ b/source/slang/emit.cpp @@ -4667,7 +4667,7 @@ emitDeclImpl(decl, nullptr); if(!isDigit(c)) { SLANG_UNEXPECTED("bad name mangling"); - return 0; + UNREACHABLE_RETURN(0); } get(); @@ -4700,7 +4700,7 @@ emitDeclImpl(decl, nullptr); if(count > (end_ - cursor_)) { SLANG_UNEXPECTED("bad name mangling"); - return result; + UNREACHABLE_RETURN(result); } result = UnownedStringSlice(cursor_, cursor_ + count); diff --git a/source/slang/ir.cpp b/source/slang/ir.cpp index 5cc73a36b..102fb947c 100644 --- a/source/slang/ir.cpp +++ b/source/slang/ir.cpp @@ -2540,7 +2540,7 @@ namespace Slang default: SLANG_UNEXPECTED("unimplemented"); - return ScalarizedVal(); + UNREACHABLE_RETURN(ScalarizedVal()); } } @@ -3064,7 +3064,7 @@ namespace Slang default: SLANG_UNEXPECTED("no value registered for IR value"); - return nullptr; + UNREACHABLE_RETURN(nullptr); } } @@ -3401,7 +3401,7 @@ namespace Slang default: SLANG_UNEXPECTED("unhandled case"); - return "unknown"; + UNREACHABLE_RETURN("unknown"); } } @@ -3503,7 +3503,7 @@ namespace Slang { // This shouldn't happen! SLANG_UNEXPECTED("no matching function registered"); - return cloneSimpleFunc(context, originalFunc); + UNREACHABLE_RETURN(cloneSimpleFunc(context, originalFunc)); } // We will try to track the "best" definition we can find. @@ -3733,7 +3733,7 @@ namespace Slang else { SLANG_UNEXPECTED("unimplemented"); - return nullptr; + UNREACHABLE_RETURN(nullptr); } } diff --git a/source/slang/lower-to-ir.cpp b/source/slang/lower-to-ir.cpp index 93b84ad31..17ebacf98 100644 --- a/source/slang/lower-to-ir.cpp +++ b/source/slang/lower-to-ir.cpp @@ -401,7 +401,7 @@ IRValue* getOneValOfType( // TODO: should make sure to handle vector and matrix types here SLANG_UNEXPECTED("inc/dec type"); - return nullptr; + UNREACHABLE_RETURN(nullptr); } LoweredValInfo emitPreOp( @@ -665,8 +665,10 @@ top: { auto boundSubscriptInfo = lowered.getBoundSubscriptInfo(); - for (auto getter : getMembersOfType<GetterDecl>(boundSubscriptInfo->declRef)) + auto getters = getMembersOfType<GetterDecl>(boundSubscriptInfo->declRef); + if (getters.Count()) { + auto& getter = *getters.begin(); lowered = emitCallToDeclRef( context, boundSubscriptInfo->type, @@ -677,7 +679,7 @@ top: } SLANG_UNEXPECTED("subscript had no getter"); - return nullptr; + UNREACHABLE_RETURN(nullptr); } break; @@ -694,7 +696,7 @@ top: default: SLANG_UNEXPECTED("unhandled value flavor"); - return nullptr; + UNREACHABLE_RETURN(nullptr); } } @@ -733,7 +735,7 @@ RefPtr<Type> getSimpleType(LoweredTypeInfo lowered) default: SLANG_UNEXPECTED("unhandled value flavor"); - return nullptr; + UNREACHABLE_RETURN(nullptr); } } @@ -1088,7 +1090,7 @@ struct ExprLoweringVisitorBase : ExprVisitor<Derived, LoweredValInfo> else { SLANG_UNIMPLEMENTED_X("codegen for deref expression"); - return LoweredValInfo(); + UNREACHABLE_RETURN(LoweredValInfo()); } } @@ -1257,7 +1259,7 @@ struct ExprLoweringVisitorBase : ExprVisitor<Derived, LoweredValInfo> else { SLANG_UNEXPECTED("shouldn't relaly happen"); - addDirectCallArgs(expr, ioArgs); + UNREACHABLE(addDirectCallArgs(expr, ioArgs)); } } @@ -1453,7 +1455,7 @@ struct ExprLoweringVisitorBase : ExprVisitor<Derived, LoweredValInfo> default: SLANG_UNIMPLEMENTED_X("subscript expr"); - return LoweredValInfo(); + UNREACHABLE_RETURN(LoweredValInfo()); } } @@ -2016,7 +2018,8 @@ top: auto type = subscriptInfo->type; // Search for an appropriate "setter" declaration - for (auto setterDeclRef : getMembersOfType<SetterDecl>(subscriptInfo->declRef)) + auto setters = getMembersOfType<SetterDecl>(subscriptInfo->declRef); + if (setters.Count()) { auto allArgs = subscriptInfo->args; @@ -2025,7 +2028,7 @@ top: emitCallToDeclRef( context, context->getSession()->getVoidType(), - setterDeclRef, + *setters.begin(), nullptr, allArgs); return; @@ -2860,7 +2863,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> // and then emit a dataflow error if this block // can't be eliminated. SLANG_UNEXPECTED("Needed a return here"); - subContext->irBuilder->emitReturn(); + UNREACHABLE(subContext->irBuilder->emitReturn()); } } } diff --git a/source/slang/lower.cpp b/source/slang/lower.cpp index 0f16a8ad7..429ebbc97 100644 --- a/source/slang/lower.cpp +++ b/source/slang/lower.cpp @@ -424,7 +424,7 @@ static SourceLoc getPosition(LoweredExpr const& expr) case LoweredExpr::Flavor::VaryingTuple: return expr.getVaryingTupleExpr()->loc; default: SLANG_UNREACHABLE("all cases handled"); - return SourceLoc(); + UNREACHABLE_RETURN(SourceLoc()); } } @@ -902,7 +902,7 @@ struct LoweringVisitor default: SLANG_UNREACHABLE("all cases handled"); - return LoweredExpr(); + UNREACHABLE_RETURN(LoweredExpr()); } } diff --git a/source/slang/parameter-binding.cpp b/source/slang/parameter-binding.cpp index fed838e6b..18294bb3e 100644 --- a/source/slang/parameter-binding.cpp +++ b/source/slang/parameter-binding.cpp @@ -567,7 +567,7 @@ getTypeLayoutForGlobalShaderParameter( default: SLANG_UNEXPECTED("unhandled source language"); - return nullptr; + UNREACHABLE_RETURN(nullptr); } } @@ -1314,7 +1314,7 @@ static RefPtr<TypeLayout> processEntryPointParameter( } SLANG_UNEXPECTED("unhandled type kind"); - return nullptr; + UNREACHABLE_RETURN(nullptr); } static void collectEntryPointParameters( diff --git a/source/slang/syntax.cpp b/source/slang/syntax.cpp index 6cf3fd7c9..149e0b811 100644 --- a/source/slang/syntax.cpp +++ b/source/slang/syntax.cpp @@ -761,7 +761,7 @@ void Type::accept(IValVisitor* visitor, void* extra) bool NamedExpressionType::EqualsImpl(Type * /*type*/) { SLANG_UNEXPECTED("unreachable"); - return false; + UNREACHABLE_RETURN(false); } Type* NamedExpressionType::CreateCanonicalType() @@ -772,7 +772,7 @@ void Type::accept(IValVisitor* visitor, void* extra) int NamedExpressionType::GetHashCode() { SLANG_UNEXPECTED("unreachable"); - return 0; + UNREACHABLE_RETURN(0); } // FuncType @@ -910,7 +910,7 @@ void Type::accept(IValVisitor* visitor, void* extra) int TypeType::GetHashCode() { SLANG_UNEXPECTED("unreachable"); - return 0; + UNREACHABLE_RETURN(0); } // GenericDeclRefType @@ -1130,7 +1130,7 @@ void Type::accept(IValVisitor* visitor, void* extra) SLANG_UNIMPLEMENTED_X("generic substitution into expressions"); - return expr; + UNREACHABLE_RETURN(expr); } @@ -1308,7 +1308,7 @@ void Type::accept(IValVisitor* visitor, void* extra) else { SLANG_UNEXPECTED("unhandled syntax class name"); - return nullptr; + UNREACHABLE_RETURN(nullptr); } } diff --git a/source/slang/type-layout.cpp b/source/slang/type-layout.cpp index 0825da6b4..bfdc6c366 100644 --- a/source/slang/type-layout.cpp +++ b/source/slang/type-layout.cpp @@ -51,7 +51,7 @@ struct DefaultLayoutRulesImpl : SimpleLayoutRulesImpl default: SLANG_UNEXPECTED("uhandled scalar type"); - return SimpleLayoutInfo( LayoutResourceKind::Uniform, 0, 1 ); + UNREACHABLE_RETURN(SimpleLayoutInfo( LayoutResourceKind::Uniform, 0, 1 )); } } @@ -76,7 +76,7 @@ struct DefaultLayoutRulesImpl : SimpleLayoutRulesImpl default: SLANG_UNEXPECTED("unhandled scalar type"); - return SimpleLayoutInfo(); + UNREACHABLE_RETURN(SimpleLayoutInfo()); } } @@ -364,8 +364,6 @@ struct GLSLPushConstantBufferObjectLayoutRulesImpl : GLSLObjectLayoutRulesImpl // Special-case the layout for a constant-buffer, because we don't // want it to allocate a descriptor-table slot return SimpleLayoutInfo(LayoutResourceKind::PushConstantBuffer, 1); - - return GLSLObjectLayoutRulesImpl::GetObjectLayout(kind); } }; GLSLPushConstantBufferObjectLayoutRulesImpl kGLSLPushConstantBufferObjectLayoutRulesImpl_; @@ -401,7 +399,7 @@ struct HLSLObjectLayoutRulesImpl : ObjectLayoutRulesImpl // TODO: how to handle these? default: SLANG_UNEXPECTED("unhandled shader parameter kind"); - return SimpleLayoutInfo(); + UNREACHABLE_RETURN(SimpleLayoutInfo()); } } }; @@ -717,7 +715,7 @@ static SimpleLayoutInfo getParameterBlockLayoutInfo( else { SLANG_UNEXPECTED("unhandled parameter block type"); - return SimpleLayoutInfo(); + UNREACHABLE_RETURN(SimpleLayoutInfo()); } } diff --git a/source/slang/vm.cpp b/source/slang/vm.cpp index f129d15e0..4b912fb7c 100644 --- a/source/slang/vm.cpp +++ b/source/slang/vm.cpp @@ -514,7 +514,7 @@ void computeTypeSizeAlign( default: SLANG_UNIMPLEMENTED_X("type sizing"); - impl->size = 0; + UNREACHABLE(impl->size = 0); break; } @@ -598,8 +598,8 @@ VMType loadVMType( return getType(vmModule->vm, impl); } - SLANG_UNEXPECTED("unimplemented"); - return VMType(); + UNREACHABLE(SLANG_UNEXPECTED("unimplemented")); + UNREACHABLE_RETURN(VMType()); break; } } |
