Modified ASTContext::getTagDeclType() to accept a NULL pointer for the passed
in TagDecl*. This allows the deserializer to use ASTContext to create the
TagTypes. Deserialize TagTypes then rely on pointer-backpatching to resolve
the decls.

This may not be the interface that we want, but as the implementation of
TagTypes will potentially change significantly in the future, I'm leaving this
for now. An appropriate FIXME is in place.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44089 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/ASTContext.cpp b/AST/ASTContext.cpp
index b844adf..9d597bc 100644
--- a/AST/ASTContext.cpp
+++ b/AST/ASTContext.cpp
@@ -717,12 +717,19 @@
 /// getTagDeclType - Return the unique reference to the type for the
 /// specified TagDecl (struct/union/class/enum) decl.
 QualType ASTContext::getTagDeclType(TagDecl *Decl) {
-  // The decl stores the type cache.
-  if (Decl->TypeForDecl) return QualType(Decl->TypeForDecl, 0);
+  // FIXME: This method currently accepts "Decl" to be NULL for use
+  //  by the deserializer.  This interface may wished to be changed
+  //  in the future.
   
-  Decl->TypeForDecl = new TagType(Decl, QualType());
-  Types.push_back(Decl->TypeForDecl);
-  return QualType(Decl->TypeForDecl, 0);
+  // The decl stores the type cache.
+  if (Decl && Decl->TypeForDecl) return QualType(Decl->TypeForDecl, 0);
+  
+  TagType* T = new TagType(Decl, QualType());
+  Types.push_back(T);
+  
+  if (Decl) Decl->TypeForDecl = T;
+
+  return QualType(T, 0);
 }
 
 /// getSizeType - Return the unique type for "size_t" (C99 7.17), the result