Merge pull request #14774 from rudkx/cs-check-type-before-getting

Update ConstraintSystem::dump to check hasType before calling getType.
diff --git a/lib/Sema/TypeCheckConstraints.cpp b/lib/Sema/TypeCheckConstraints.cpp
index fc1e097..d97a6bd 100644
--- a/lib/Sema/TypeCheckConstraints.cpp
+++ b/lib/Sema/TypeCheckConstraints.cpp
@@ -3121,9 +3121,15 @@
 }
 
 void ConstraintSystem::dump(Expr *E) {
-  auto getTypeOfExpr = [&](const Expr *E) -> Type { return getType(E); };
+  auto getTypeOfExpr = [&](const Expr *E) -> Type {
+    if (hasType(E))
+      return getType(E);
+    return Type();
+  };
   auto getTypeOfTypeLoc = [&](const TypeLoc &TL) -> Type {
-    return getType(TL);
+    if (hasType(TL))
+      return getType(TL);
+    return Type();
   };
 
   E->dump(getTypeOfExpr, getTypeOfTypeLoc);