Skip to content

Commit d60d6dd

Browse files
committed
[gardening] Propagate type info to silence static analyzer nullptr error.
The static analyzer flags this as a nullptr dereference since FullApplySite::isa can fail if given a non-ApplySite. Of course though, the SILInstruction is an apply! We just created it! This commit helps the static analyzer by propagating this type information by not downcasting our ApplyInst to SILInstruction and then just use FullApplySite's ApplyInst constructor instead.
1 parent d8f5b20 commit d60d6dd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,9 @@ SILCombiner::optimizeApplyOfConvertFunctionInst(FullApplySite AI,
207207
// we got this far it is legal to perform the transformation (since
208208
// otherwise, we would be creating malformed SIL).
209209
bool setNonThrowing = FRI->getFunctionType()->hasErrorResult();
210-
SILInstruction *NAI = Builder.createApply(AI.getLoc(), FRI, SubstitutionMap(),
211-
Args, setNonThrowing);
212-
assert(FullApplySite::isa(NAI).getSubstCalleeType()->getAllResultsSubstType(
210+
ApplyInst *NAI = Builder.createApply(AI.getLoc(), FRI, SubstitutionMap(),
211+
Args, setNonThrowing);
212+
assert(FullApplySite(NAI).getSubstCalleeType()->getAllResultsSubstType(
213213
AI.getModule(), AI.getFunction()->getTypeExpansionContext()) ==
214214
AI.getSubstCalleeType()->getAllResultsSubstType(
215215
AI.getModule(), AI.getFunction()->getTypeExpansionContext()) &&

0 commit comments

Comments
 (0)