Skip to content

Commit 77fb90e

Browse files
committed
[Sema/SILGen] Add asserts to getParameterAt call sites that expect non-null parameter
1 parent 7bc1dc5 commit 77fb90e

File tree

5 files changed

+15
-2
lines changed

5 files changed

+15
-2
lines changed

lib/SILGen/SILGen.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,8 @@ void SILGenModule::emitFunctionDefinition(SILDeclRef constant, SILFunction *f) {
907907
case SILDeclRef::Kind::DefaultArgGenerator: {
908908
auto *decl = constant.getDecl();
909909
auto *param = getParameterAt(decl, constant.defaultArgIndex);
910+
assert(param);
911+
910912
auto *initDC = param->getDefaultArgumentInitContext();
911913

912914
switch (param->getDefaultArgumentKind()) {

lib/SILGen/SILGenFunction.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ void SILGenFunction::emitCaptures(SILLocation loc,
254254
if (closure.kind == SILDeclRef::Kind::DefaultArgGenerator) {
255255
auto *param = getParameterAt(closure.getDecl(),
256256
closure.defaultArgIndex);
257+
assert(param);
257258
loc = param->getLoc();
258259
} else {
259260
auto f = *closure.getAnyFunctionRef();

lib/Sema/CSApply.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5497,6 +5497,7 @@ Solution::resolveLocatorToDecl(ConstraintLocator *locator) const {
54975497
static ConcreteDeclRef getDefaultArgOwner(ConcreteDeclRef owner,
54985498
unsigned index) {
54995499
auto *param = getParameterAt(owner.getDecl(), index);
5500+
assert(param);
55005501
if (param->getDefaultArgumentKind() == DefaultArgumentKind::Inherited) {
55015502
return getDefaultArgOwner(owner.getOverriddenDecl(), index);
55025503
}
@@ -6034,6 +6035,8 @@ ArgumentList *ExprRewriter::coerceCallArguments(
60346035

60356036
if (paramInfo.hasExternalPropertyWrapper(paramIdx)) {
60366037
auto *paramDecl = getParameterAt(callee.getDecl(), paramIdx);
6038+
assert(paramDecl);
6039+
60376040
auto appliedWrapper = appliedPropertyWrappers[appliedWrapperIndex++];
60386041
auto wrapperType = solution.simplifyType(appliedWrapper.wrapperType);
60396042
auto initKind = appliedWrapper.initKind;

lib/Sema/CSSimplify.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,6 +1898,7 @@ static ConstraintSystem::TypeMatchResult matchCallArguments(
18981898
auto argLabel = argument.getLabel();
18991899
if (paramInfo.hasExternalPropertyWrapper(argIdx) || argLabel.hasDollarPrefix()) {
19001900
auto *param = getParameterAt(callee, argIdx);
1901+
assert(param);
19011902
if (cs.applyPropertyWrapperToParameter(paramTy, argTy, const_cast<ParamDecl *>(param),
19021903
argLabel, subKind, loc).isFailure()) {
19031904
return cs.getTypeMatchFailure(loc);
@@ -10535,6 +10536,8 @@ static Type getOpenedResultBuilderTypeFor(ConstraintSystem &cs,
1053510536
return Type();
1053610537

1053710538
auto *PD = getParameterAt(choice, argToParamElt->getParamIdx());
10539+
assert(PD);
10540+
1053810541
auto builderType = PD->getResultBuilderType();
1053910542
if (!builderType)
1054010543
return Type();

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,12 +697,16 @@ CheckRedeclarationRequest::evaluate(Evaluator &eval, ValueDecl *current) const {
697697

698698
if (currParams[i].getPlainType()->getOptionalObjectType()) {
699699
optionalRedecl = true;
700-
if (swift::getParameterAt(current, i)->isImplicitlyUnwrappedOptional())
700+
auto *param = swift::getParameterAt(current, i);
701+
assert(param);
702+
if (param->isImplicitlyUnwrappedOptional())
701703
currIsIUO = true;
702704
}
703705

704706
if (otherParams[i].getPlainType()->getOptionalObjectType()) {
705-
if (swift::getParameterAt(other, i)->isImplicitlyUnwrappedOptional())
707+
auto *param = swift::getParameterAt(other, i);
708+
assert(param);
709+
if (param->isImplicitlyUnwrappedOptional())
706710
otherIsIUO = true;
707711
}
708712
else {

0 commit comments

Comments
 (0)