Fix a crash when there is a typo in the return statement.
If the typo happens after a successful deduction for an earlier
return statement, we should check if the deduced type is null
before using it.
The typo correction happens after we try to deduce the return
type and we ignore the deduction from the typo and continue
to typo correction.
rdar://24342247
llvm-svn: 259820
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index d734416..836073a 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -3069,6 +3069,11 @@
QualType DeducedT = AT->getDeducedType();
if (!DeducedT.isNull() && !FD->isInvalidDecl()) {
AutoType *NewAT = Deduced->getContainedAutoType();
+ // It is possible that NewAT->getDeducedType() is null. When that happens,
+ // we should not crash, instead we ignore this deduction.
+ if (NewAT->getDeducedType().isNull())
+ return false;
+
CanQualType OldDeducedType = Context.getCanonicalFunctionResultType(
DeducedT);
CanQualType NewDeducedType = Context.getCanonicalFunctionResultType(