Fix crasher spotted in IWYU.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131222 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 1f0bd4c..f6cce0b 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2314,7 +2314,8 @@
     Pattern = PatternDecl->getBody(PatternDecl);
 
   // Postpone late parsed template instantiations.
-  if (PatternDecl->isLateTemplateParsed() && !LateTemplateParser) {
+  if (PatternDecl && PatternDecl->isLateTemplateParsed() &&
+      !LateTemplateParser) {
     PendingInstantiations.push_back(
       std::make_pair(Function, PointOfInstantiation));
     return;