diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-05-11 13:56:14 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-11 13:56:14 -0700 |
| commit | 5e604a6f39ef8e8086702d41113ea78856804c99 (patch) | |
| tree | 035a4de9b84bdc04f377344dcaea931aa1896fa4 /source | |
| parent | 10c0ffa7de111bd2c0096015bba5ca2110d03bc1 (diff) | |
Cleanups around behavior when the compiler fails (#553)
* Cleanups around behavior when the compiler fails
* Add another case where we try to `noteInternalErrorLoc()` if an exception in thrown. This one is the in the logic for emitting an IR instruciton. This could be improved by adding another layer at the function level (as a catch-all for instructions with no location), but something is better than nothing.
* Change a bunch of `assert()`s over to `SLANG_ASSERT()`s, so that we can theoretically take more control over them (e.g., make release builds with asserts enabled)
* Some other small cleanups around the assertions we perform.
In the survey I made, I didn't really see many obvious "smoking gun" cases where we could produce a significantly better error message for some of the unimplemented/unexpected paths, other than to actually implement the missing functionality.
* fixup
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/check.cpp | 29 | ||||
| -rw-r--r-- | source/slang/emit.cpp | 53 | ||||
| -rw-r--r-- | source/slang/ir-insts.h | 4 | ||||
| -rw-r--r-- | source/slang/ir-legalize-types.cpp | 8 | ||||
| -rw-r--r-- | source/slang/ir-ssa.cpp | 26 | ||||
| -rw-r--r-- | source/slang/ir.cpp | 39 | ||||
| -rw-r--r-- | source/slang/legalize-types.h | 14 | ||||
| -rw-r--r-- | source/slang/lower-to-ir.cpp | 24 | ||||
| -rw-r--r-- | source/slang/parameter-binding.cpp | 4 |
9 files changed, 111 insertions, 90 deletions
diff --git a/source/slang/check.cpp b/source/slang/check.cpp index a94812687..67c747861 100644 --- a/source/slang/check.cpp +++ b/source/slang/check.cpp @@ -3021,7 +3021,7 @@ namespace Slang void ValidateFunctionRedeclaration(FuncDecl* funcDecl) { auto parentDecl = funcDecl->ParentDecl; - SLANG_RELEASE_ASSERT(parentDecl); + SLANG_ASSERT(parentDecl); if (!parentDecl) return; Decl* childDecl = funcDecl; @@ -3094,7 +3094,7 @@ namespace Slang // consider if their generic signatures match. if (genericDecl) { - assert(prevGenericDecl); + SLANG_ASSERT(prevGenericDecl); // already checked above if (!doGenericSignaturesMatch(genericDecl, prevGenericDecl)) continue; @@ -4436,6 +4436,9 @@ namespace Slang // in order for checking to suceed. struct ConstraintSystem { + // A source location to use in reporting any issues + SourceLoc loc; + // The generic declaration whose parameters we // are trying to solve for. RefPtr<GenericDecl> genericDecl; @@ -4750,7 +4753,7 @@ namespace Slang return left; else { - SLANG_ASSERT(rightFlavor > leftFlavor); + SLANG_ASSERT(rightFlavor > leftFlavor); // equality was handles at the top of this function return right; } } @@ -5377,13 +5380,13 @@ namespace Slang return true; auto genericDeclRef = candidate.item.declRef.As<GenericDecl>(); - assert(genericDeclRef); + SLANG_ASSERT(genericDeclRef); // otherwise we wouldn't be a generic candidate... // We should have the existing arguments to the generic // handy, so that we can construct a substitution list. RefPtr<GenericSubstitution> subst = candidate.subst.As<GenericSubstitution>(); - assert(subst); + SLANG_ASSERT(subst); subst->genericDecl = genericDeclRef.getDecl(); subst->outer = genericDeclRef.substitutions.substitutions; @@ -5853,15 +5856,15 @@ namespace Slang { auto constraintDecl1 = fstWit->declRef.As<TypeConstraintDecl>(); auto constraintDecl2 = sndWit->declRef.As<TypeConstraintDecl>(); - assert(constraintDecl1); - assert(constraintDecl2); + SLANG_ASSERT(constraintDecl1); + SLANG_ASSERT(constraintDecl2); return TryUnifyTypes(constraints, constraintDecl1.getDecl()->getSup().type, constraintDecl2.getDecl()->getSup().type); } } - throw "unimplemented"; + SLANG_UNIMPLEMENTED_X("value unification case"); // default: fail return false; @@ -6111,6 +6114,7 @@ namespace Slang if (auto extGenericDecl = GetOuterGeneric(extDecl)) { ConstraintSystem constraints; + constraints.loc = extDecl->loc; constraints.genericDecl = extGenericDecl; if (!TryUnifyTypes(constraints, extDecl->targetType.Ptr(), type)) @@ -6229,12 +6233,13 @@ namespace Slang // so that the resulting inner declaration can be applicable in // a particular context... DeclRef<Decl> SpecializeGenericForOverload( - DeclRef<GenericDecl> genericDeclRef, - OverloadResolveContext& context) + DeclRef<GenericDecl> genericDeclRef, + OverloadResolveContext& context) { checkDecl(genericDeclRef.getDecl()); ConstraintSystem constraints; + constraints.loc = context.loc; constraints.genericDecl = genericDeclRef.getDecl(); // Construct a reference to the inner declaration that has any generic @@ -6363,7 +6368,7 @@ namespace Slang // We expect the parent of the generic type parameter to be a generic... auto genericDeclRef = typeDeclRef.GetParent().As<GenericDecl>(); - assert(genericDeclRef); + SLANG_ASSERT(genericDeclRef); for(auto constraintDeclRef : getMembersOfType<GenericTypeConstraintDecl>(genericDeclRef)) { @@ -7585,7 +7590,7 @@ namespace Slang bool isPrimaryDecl( CallableDecl* decl) { - assert(decl); + SLANG_ASSERT(decl); return (!decl->primaryDecl) || (decl == decl->primaryDecl); } diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp index bf7fceb0e..edb5d5cb2 100644 --- a/source/slang/emit.cpp +++ b/source/slang/emit.cpp @@ -3453,11 +3453,11 @@ struct EmitVisitor for (UInt ee = 0; ee < elementCount; ++ee) { IRInst* irElementIndex = ii->getElementIndex(ee); - assert(irElementIndex->op == kIROp_IntLit); + SLANG_RELEASE_ASSERT(irElementIndex->op == kIROp_IntLit); IRConstant* irConst = (IRConstant*)irElementIndex; UInt elementIndex = (UInt)irConst->u.intVal; - assert(elementIndex < 4); + SLANG_RELEASE_ASSERT(elementIndex < 4); char const* kComponents[] = { "x", "y", "z", "w" }; emit(kComponents[elementIndex]); @@ -3514,6 +3514,25 @@ struct EmitVisitor IRInst* inst, IREmitMode mode) { + try + { + emitIRInstImpl(ctx, inst, mode); + } + // Don't emit any context message for an explicit `AbortCompilationException` + // because it should only happen when an error is already emitted. + catch(AbortCompilationException&) { throw; } + catch(...) + { + ctx->shared->entryPoint->compileRequest->noteInternalErrorLoc(inst->sourceLoc); + throw; + } + } + + void emitIRInstImpl( + EmitContext* ctx, + IRInst* inst, + IREmitMode mode) + { if (shouldFoldIRInstIntoUseSites(ctx, inst, mode)) { return; @@ -3584,11 +3603,11 @@ struct EmitVisitor for (UInt ee = 0; ee < elementCount; ++ee) { IRInst* irElementIndex = ii->getElementIndex(ee); - assert(irElementIndex->op == kIROp_IntLit); + SLANG_RELEASE_ASSERT(irElementIndex->op == kIROp_IntLit); IRConstant* irConst = (IRConstant*)irElementIndex; UInt elementIndex = (UInt)irConst->u.intVal; - assert(elementIndex < 4); + SLANG_RELEASE_ASSERT(elementIndex < 4); char const* kComponents[] = { "x", "y", "z", "w" }; emit(kComponents[elementIndex]); @@ -3609,11 +3628,11 @@ struct EmitVisitor for (UInt ee = 0; ee < elementCount; ++ee) { IRInst* irElementIndex = ii->getElementIndex(ee); - assert(irElementIndex->op == kIROp_IntLit); + SLANG_RELEASE_ASSERT(irElementIndex->op == kIROp_IntLit); IRConstant* irConst = (IRConstant*)irElementIndex; UInt elementIndex = (UInt)irConst->u.intVal; - assert(elementIndex < 4); + SLANG_RELEASE_ASSERT(elementIndex < 4); char const* kComponents[] = { "x", "y", "z", "w" }; emit(kComponents[elementIndex]); @@ -3717,7 +3736,7 @@ struct EmitVisitor if (argIndex >= argCount) { - assert(!"not enough arguments for branch"); + SLANG_UNEXPECTED("not enough arguments for branch"); break; } @@ -3822,7 +3841,7 @@ struct EmitVisitor // Start by emitting the non-terminator instructions in the block. auto terminator = block->getLastInst(); - assert(as<IRTerminatorInst>(terminator)); + SLANG_ASSERT(as<IRTerminatorInst>(terminator)); for (auto inst = block->getFirstInst(); inst != terminator; inst = inst->getNextInst()) { emitIRInst(ctx, inst, IREmitMode::Default); @@ -5003,7 +5022,7 @@ struct EmitVisitor Emit(ctx->shared->uniqueIDCounter++); auto varLayout = getVarLayout(ctx, varDecl); - assert(varLayout); + SLANG_RELEASE_ASSERT(varLayout); EmitVarChain blockChain(varLayout); @@ -5051,7 +5070,7 @@ struct EmitVisitor emit(getIRName(varDecl)); auto varLayout = getVarLayout(ctx, varDecl); - assert(varLayout); + SLANG_RELEASE_ASSERT(varLayout); EmitVarChain blockChain(varLayout); @@ -5077,7 +5096,7 @@ struct EmitVisitor if(auto structType = as<IRStructType>(elementType)) { auto structTypeLayout = typeLayout.As<StructTypeLayout>(); - assert(structTypeLayout); + SLANG_RELEASE_ASSERT(structTypeLayout); UInt fieldIndex = 0; for(auto ff : structType->getFields()) @@ -5133,7 +5152,7 @@ struct EmitVisitor IRParameterBlockType* type) { auto varLayout = getVarLayout(ctx, varDecl); - assert(varLayout); + SLANG_RELEASE_ASSERT(varLayout); EmitVarChain blockChain(varLayout); @@ -5180,7 +5199,7 @@ struct EmitVisitor } auto varLayout = getVarLayout(ctx, varDecl); - assert(varLayout); + SLANG_RELEASE_ASSERT(varLayout); EmitVarChain blockChain(varLayout); @@ -5218,7 +5237,7 @@ struct EmitVisitor if(auto structType = as<IRStructType>(elementType)) { auto structTypeLayout = typeLayout.As<StructTypeLayout>(); - assert(structTypeLayout); + SLANG_RELEASE_ASSERT(structTypeLayout); UInt fieldIndex = 0; for(auto ff : structType->getFields()) @@ -5501,13 +5520,13 @@ struct EmitVisitor { // We expect to see only a single block auto block = valDecl->getFirstBlock(); - assert(block); - assert(!block->getNextBlock()); + SLANG_RELEASE_ASSERT(block); + SLANG_RELEASE_ASSERT(!block->getNextBlock()); // We expect the terminator to be a `return` // instruction with a value. auto returnInst = (IRReturnVal*) block->getLastInst(); - assert(returnInst->op == kIROp_ReturnVal); + SLANG_RELEASE_ASSERT(returnInst->op == kIROp_ReturnVal); // Now we want to emit the expression form of // the value being returned, and force any diff --git a/source/slang/ir-insts.h b/source/slang/ir-insts.h index 804c393c2..f35c391cf 100644 --- a/source/slang/ir-insts.h +++ b/source/slang/ir-insts.h @@ -823,7 +823,7 @@ struct IRBuilder template<typename T> T* addDecoration(IRInst* value, IRDecorationOp op) { - assert(getModule()); + SLANG_ASSERT(getModule()); auto decorationSize = sizeof(T); auto decoration = (T*)getModule()->memoryPool.allocZero(decorationSize); new(decoration)T(); @@ -867,7 +867,7 @@ struct IRBuilderSourceLocRAII ~IRBuilderSourceLocRAII() { - assert(builder->sourceLocInfo == this); + SLANG_ASSERT(builder->sourceLocInfo == this); builder->sourceLocInfo = next; } }; diff --git a/source/slang/ir-legalize-types.cpp b/source/slang/ir-legalize-types.cpp index 3465662f3..05b8ca647 100644 --- a/source/slang/ir-legalize-types.cpp +++ b/source/slang/ir-legalize-types.cpp @@ -68,7 +68,7 @@ LegalVal LegalVal::implicitDeref(LegalVal const& val) LegalVal LegalVal::getImplicitDeref() { - assert(flavor == Flavor::implicitDeref); + SLANG_ASSERT(flavor == Flavor::implicitDeref); return obj.As<ImplicitDerefVal>()->val; } @@ -622,10 +622,10 @@ static LegalVal legalizeGetElementPtr( RefPtr<TuplePseudoVal> resTupleInfo = new TuplePseudoVal(); auto tupleType = type.getTuple(); - assert(tupleType); + SLANG_ASSERT(tupleType); auto elemCount = ptrTupleInfo->elements.Count(); - assert(elemCount == tupleType->elements.Count()); + SLANG_ASSERT(elemCount == tupleType->elements.Count()); for(UInt ee = 0; ee < elemCount; ++ee) { @@ -951,7 +951,7 @@ static void addParamType(List<IRType*>& ioParamTypes, LegalType t) } break; default: - SLANG_ASSERT(false); + SLANG_UNEXPECTED("unknown legalized type flavor"); } } diff --git a/source/slang/ir-ssa.cpp b/source/slang/ir-ssa.cpp index b2d336507..207938a90 100644 --- a/source/slang/ir-ssa.cpp +++ b/source/slang/ir-ssa.cpp @@ -189,7 +189,7 @@ bool isPromotableVar( { // A load has only a single argument, so // it had better be our pointer. - assert(u == &((IRLoad*) user)->ptr); + SLANG_ASSERT(u == &((IRLoad*) user)->ptr); } break; @@ -206,7 +206,7 @@ bool isPromotableVar( // Otherwise our variable is being used // as the destination for the store, and // that is okay by us. - assert(u == &storeInst->ptr); + SLANG_ASSERT(u == &storeInst->ptr); } break; @@ -410,7 +410,7 @@ IRInst* tryRemoveTrivialPhi( for (auto u : phiInfo->operands) { auto usedVal = u.get(); - assert(usedVal); + SLANG_ASSERT(usedVal); if (usedVal == same || usedVal == phi) { @@ -440,8 +440,7 @@ IRInst* tryRemoveTrivialPhi( // There were no operands other than the phi itself. // This implies that the value at the use sites should // actually be undefined. - - assert(!"unimplemented"); + SLANG_UNIMPLEMENTED_X("trivial phi"); } // Removing this phi as trivial may make other phi nodes @@ -504,7 +503,7 @@ IRInst* addPhiOperands( // Precondition: if we have multiple predecessors, then // each must have only one successor (no critical edges). // - assert(predBlock->getSuccessors().getCount() == 1); + SLANG_ASSERT(predBlock->getSuccessors().getCount() == 1); auto predInfo = *context->blockInfos.TryGetValue(predBlock); @@ -888,11 +887,8 @@ static void breakCriticalEdges( for (auto edgeUse : criticalEdges) { - auto pred = (IRBlock*) edgeUse->getUser()->parent; - assert(pred->op == kIROp_Block); - - auto succ = (IRBlock*)edgeUse->get(); - assert(succ->op == kIROp_Block); + auto pred = cast<IRBlock>(edgeUse->getUser()->parent); + auto succ = cast<IRBlock>(edgeUse->get()); IRBuilder builder; builder.sharedBuilder = &context->sharedBuilder; @@ -999,8 +995,8 @@ void constructSSA(ConstructSSAContext* context) auto blockInfo = * context->blockInfos.TryGetValue(bb); // Sanity check: all blocks should be filled and sealed. - assert(blockInfo->isSealed); - assert(blockInfo->isFilled); + SLANG_ASSERT(blockInfo->isSealed); + SLANG_ASSERT(blockInfo->isFilled); // Don't do any work for blocks that don't need to pass along // values to the sucessor block. @@ -1012,7 +1008,7 @@ void constructSSA(ConstructSSAContext* context) // has additional arguments. IRTerminatorInst* oldTerminator = bb->getTerminator(); - assert(oldTerminator); + SLANG_ASSERT(oldTerminator); blockInfo->builder.setInsertInto(bb); @@ -1041,7 +1037,7 @@ void constructSSA(ConstructSSAContext* context) // A terminator better not have uses, so we shouldn't have // to replace them. - assert(!oldTerminator->firstUse); + SLANG_ASSERT(!oldTerminator->firstUse); // Okay, we should be clear to remove the old terminator diff --git a/source/slang/ir.cpp b/source/slang/ir.cpp index a7cc342ae..c2d900fdd 100644 --- a/source/slang/ir.cpp +++ b/source/slang/ir.cpp @@ -322,8 +322,8 @@ namespace Slang break; default: - assert(!"unepxected"); - return IRBlock::SuccessorList(nullptr, nullptr); + SLANG_UNEXPECTED("unhandled terminator instruction"); + UNREACHABLE_RETURN(IRBlock::SuccessorList(nullptr, nullptr)); } return IRBlock::SuccessorList(begin, end, stride); @@ -790,7 +790,7 @@ namespace Slang size = sizeof(T); } - assert(module); + SLANG_ASSERT(module); T* inst = (T*)module->memoryPool.allocZero(size); new(inst)T(); @@ -2846,7 +2846,7 @@ namespace Slang { // The uses had better all be uses of this // instruction, or invariants are broken. - assert(uu->get() == this); + SLANG_ASSERT(uu->get() == this); // Swap this use over to use the other value. uu->usedValue = other; @@ -2863,7 +2863,7 @@ namespace Slang // We are at the last use (and there must // be at least one, because we handled // the case of an empty list earlier). - assert(uu); + SLANG_ASSERT(uu); // Our job at this point is to splice // our list of uses onto the other @@ -2906,13 +2906,13 @@ namespace Slang // as `other`, right before it. void IRInst::insertBefore(IRInst* other) { - assert(other); + SLANG_ASSERT(other); insertBefore(other, other->parent); } void IRInst::insertAtStart(IRParentInst* newParent) { - assert(newParent); + SLANG_ASSERT(newParent); insertBefore(newParent->children.first, newParent); } @@ -2928,10 +2928,10 @@ namespace Slang // Make sure this instruction has been removed from any previous parent this->removeFromParent(); - assert(other || newParent); + SLANG_ASSERT(other || newParent); if (!other) other = newParent->children.first; if (!newParent) newParent = other->parent; - assert(newParent); + SLANG_ASSERT(newParent); auto nn = other; auto pp = other ? other->getPrevInst() : nullptr; @@ -2961,13 +2961,13 @@ namespace Slang void IRInst::insertAfter(IRInst* other) { - assert(other); + SLANG_ASSERT(other); insertAfter(other, other->parent); } void IRInst::insertAtEnd(IRParentInst* newParent) { - assert(newParent); + SLANG_ASSERT(newParent); insertAfter(newParent->children.last, newParent); } @@ -2983,10 +2983,10 @@ namespace Slang // Make sure this instruction has been removed from any previous parent this->removeFromParent(); - assert(other || newParent); + SLANG_ASSERT(other || newParent); if (!other) other = newParent->children.last; if (!newParent) newParent = other->parent; - assert(newParent); + SLANG_ASSERT(newParent); auto pp = other; auto nn = other ? other->next : nullptr; @@ -3581,7 +3581,8 @@ namespace Slang RefPtr<TypeLayout> typeLayout = inTypeLayout; for( auto dd = declarator; dd; dd = dd->next ) { - assert(dd->flavor == GlobalVaryingDeclarator::Flavor::array); + // We only have one declarator case right now... + SLANG_ASSERT(dd->flavor == GlobalVaryingDeclarator::Flavor::array); auto arrayType = builder->getArrayType( type, @@ -3754,7 +3755,7 @@ namespace Slang IRType* fullType = type; for( auto dd = declarator; dd; dd = dd->next ) { - assert(dd->flavor == GlobalVaryingDeclarator::Flavor::array); + SLANG_ASSERT(dd->flavor == GlobalVaryingDeclarator::Flavor::array); fullType = builder->getArrayType( fullType, dd->elementCount); @@ -4083,7 +4084,7 @@ namespace Slang ScalarizedVal val) { auto tupleVal = val.impl.As<ScalarizedTupleValImpl>(); - assert(tupleVal); + SLANG_ASSERT(tupleVal); UInt elementCount = tupleVal->elements.Count(); auto type = tupleVal->type; @@ -4222,7 +4223,7 @@ namespace Slang // TODO: the right thing to do here is to split any // function that both gets called as an entry point // and as an ordinary function. - assert(!func->firstUse); + SLANG_ASSERT(!func->firstUse); // We create a dummy IR builder, since some of // the functions require it. @@ -4332,7 +4333,7 @@ namespace Slang // Note that this means that any transformations that mess // with function signatures will need to also update layout info... // - assert(entryPointLayout->fields.Count() > paramIndex); + SLANG_ASSERT(entryPointLayout->fields.Count() > paramIndex); auto paramLayout = entryPointLayout->fields[paramIndex]; // We need to create a global variable that will replace the parameter. @@ -5195,7 +5196,7 @@ namespace Slang IRBlock* cb = clonedValue->getFirstBlock(); while (ob) { - assert(cb); + SLANG_ASSERT(cb); builder->setInsertInto(cb); for (auto oi = ob->getFirstInst(); oi; oi = oi->getNextInst()) diff --git a/source/slang/legalize-types.h b/source/slang/legalize-types.h index 887f263f8..c4cafe157 100644 --- a/source/slang/legalize-types.h +++ b/source/slang/legalize-types.h @@ -80,7 +80,7 @@ struct LegalType IRType* getSimple() const { - assert(flavor == Flavor::simple); + SLANG_ASSERT(flavor == Flavor::simple); return irType; } @@ -89,7 +89,7 @@ struct LegalType RefPtr<ImplicitDerefType> getImplicitDeref() const { - assert(flavor == Flavor::implicitDeref); + SLANG_ASSERT(flavor == Flavor::implicitDeref); return obj.As<ImplicitDerefType>(); } @@ -98,7 +98,7 @@ struct LegalType RefPtr<TuplePseudoType> getTuple() const { - assert(flavor == Flavor::tuple); + SLANG_ASSERT(flavor == Flavor::tuple); return obj.As<TuplePseudoType>(); } @@ -112,7 +112,7 @@ struct LegalType RefPtr<PairPseudoType> getPair() const { - assert(flavor == Flavor::pair); + SLANG_ASSERT(flavor == Flavor::pair); return obj.As<PairPseudoType>(); } }; @@ -292,7 +292,7 @@ struct LegalVal IRInst* getSimple() { - assert(flavor == Flavor::simple); + SLANG_ASSERT(flavor == Flavor::simple); return irValue; } @@ -300,7 +300,7 @@ struct LegalVal RefPtr<TuplePseudoVal> getTuple() { - assert(flavor == Flavor::tuple); + SLANG_ASSERT(flavor == Flavor::tuple); return obj.As<TuplePseudoVal>(); } @@ -315,7 +315,7 @@ struct LegalVal RefPtr<PairPseudoVal> getPair() { - assert(flavor == Flavor::pair); + SLANG_ASSERT(flavor == Flavor::pair); return obj.As<PairPseudoVal>(); } }; diff --git a/source/slang/lower-to-ir.cpp b/source/slang/lower-to-ir.cpp index 03d6ad321..81520abf5 100644 --- a/source/slang/lower-to-ir.cpp +++ b/source/slang/lower-to-ir.cpp @@ -168,7 +168,7 @@ struct LoweredValInfo BoundMemberInfo* getBoundMemberInfo() { - assert(flavor == Flavor::BoundMember); + SLANG_ASSERT(flavor == Flavor::BoundMember); return (BoundMemberInfo*)ext; } @@ -177,7 +177,7 @@ struct LoweredValInfo SubscriptInfo* getSubscriptInfo() { - assert(flavor == Flavor::Subscript); + SLANG_ASSERT(flavor == Flavor::Subscript); return (SubscriptInfo*)ext; } @@ -186,7 +186,7 @@ struct LoweredValInfo BoundSubscriptInfo* getBoundSubscriptInfo() { - assert(flavor == Flavor::BoundSubscript); + SLANG_ASSERT(flavor == Flavor::BoundSubscript); return (BoundSubscriptInfo*)ext; } @@ -195,7 +195,7 @@ struct LoweredValInfo SwizzledLValueInfo* getSwizzledLValueInfo() { - assert(flavor == Flavor::SwizzledLValue); + SLANG_ASSERT(flavor == Flavor::SwizzledLValue); return (SwizzledLValueInfo*)ext; } }; @@ -410,7 +410,7 @@ IROp getIntrinsicOp( auto nameText = getText(name); IROp op = findIROp(nameText.Buffer()); - assert(op != kIROp_Invalid); + SLANG_ASSERT(op != kIROp_Invalid); return op; } @@ -443,7 +443,7 @@ LoweredValInfo emitCompoundAssignOp( { auto builder = context->irBuilder; SLANG_UNREFERENCED_PARAMETER(argCount); - assert(argCount == 2); + SLANG_ASSERT(argCount == 2); auto leftPtr = args[0]; auto rightVal = args[1]; @@ -492,7 +492,7 @@ LoweredValInfo emitPreOp( { auto builder = context->irBuilder; SLANG_UNREFERENCED_PARAMETER(argCount); - assert(argCount == 1); + SLANG_ASSERT(argCount == 1); auto argPtr = args[0]; auto preVal = builder->emitLoad(argPtr); @@ -516,7 +516,7 @@ LoweredValInfo emitPostOp( { auto builder = context->irBuilder; SLANG_UNREFERENCED_PARAMETER(argCount); - assert(argCount == 1); + SLANG_ASSERT(argCount == 1); auto argPtr = args[0]; auto preVal = builder->emitLoad(argPtr); @@ -1709,7 +1709,7 @@ struct ExprLoweringVisitorBase : ExprVisitor<Derived, LoweredValInfo> // Now we can pass the address of the temporary variable // to the callee as the actual argument for the `in out` - assert(tempVar.flavor == LoweredValInfo::Flavor::Ptr); + SLANG_ASSERT(tempVar.flavor == LoweredValInfo::Flavor::Ptr); (*ioArgs).Add(tempVar.val); // Finally, after the call we will need @@ -3712,7 +3712,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> IRInst* fieldKeyInst = getSimpleVal(context, ensureDecl(context, fieldDecl)); auto fieldKey = as<IRStructKey>(fieldKeyInst); - assert(fieldKey); + SLANG_ASSERT(fieldKey); // Note: we lower the type of the field in the "sub" // context, so that any generic parameters that were @@ -4626,12 +4626,12 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> // to avoid emitting a bunch of extra definitions in the IR. auto primaryFuncDecl = dynamic_cast<FunctionDeclBase*>(primaryDecl); - assert(primaryFuncDecl); + SLANG_ASSERT(primaryFuncDecl); LoweredValInfo result = lowerFuncDecl(primaryFuncDecl); for (auto dd = primaryDecl->nextDecl; dd; dd = dd->nextDecl) { auto funcDecl = dynamic_cast<FunctionDeclBase*>(dd); - assert(funcDecl); + SLANG_ASSERT(funcDecl); lowerFuncDecl(funcDecl); } return result; diff --git a/source/slang/parameter-binding.cpp b/source/slang/parameter-binding.cpp index e0cc26f2b..e5fddac02 100644 --- a/source/slang/parameter-binding.cpp +++ b/source/slang/parameter-binding.cpp @@ -447,7 +447,7 @@ static void diagnoseParameterTypeMismatch( ParameterBindingContext* context, StructuralTypeMatchStack* inStack) { - assert(inStack); + SLANG_ASSERT(inStack); // The bottom-most entry in the stack should represent // the shader parameters that kicked things off @@ -466,7 +466,7 @@ static void diagnoseTypeMismatch( StructuralTypeMatchStack* inStack) { auto stack = inStack; - assert(stack); + SLANG_ASSERT(stack); diagnoseParameterTypeMismatch(context, stack); auto leftType = GetType(stack->leftDecl); |
