Make sure LLDB can deal with forward declarations to enums without crashing or asserting.

<rdar://problem/23776428> 

llvm-svn: 268098
diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp
index e80faa1..6b61646 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -8545,24 +8545,28 @@
                     clang::ASTContext *ast = lldb_ast->getASTContext();
 
                     /// TODO This really needs to be fixed.
-                    
-                    unsigned NumPositiveBits = 1;
-                    unsigned NumNegativeBits = 0;
-                    
-                    clang::QualType promotion_qual_type;
-                    // If the enum integer type is less than an integer in bit width,
-                    // then we must promote it to an integer size.
-                    if (ast->getTypeSize(enum_decl->getIntegerType()) < ast->getTypeSize(ast->IntTy))
+
+                    QualType integer_type(enum_decl->getIntegerType());
+                    if (!integer_type.isNull())
                     {
-                        if (enum_decl->getIntegerType()->isSignedIntegerType())
-                            promotion_qual_type = ast->IntTy;
+                        unsigned NumPositiveBits = 1;
+                        unsigned NumNegativeBits = 0;
+                        
+                        clang::QualType promotion_qual_type;
+                        // If the enum integer type is less than an integer in bit width,
+                        // then we must promote it to an integer size.
+                        if (ast->getTypeSize(enum_decl->getIntegerType()) < ast->getTypeSize(ast->IntTy))
+                        {
+                            if (enum_decl->getIntegerType()->isSignedIntegerType())
+                                promotion_qual_type = ast->IntTy;
+                            else
+                                promotion_qual_type = ast->UnsignedIntTy;
+                        }
                         else
-                            promotion_qual_type = ast->UnsignedIntTy;
+                            promotion_qual_type = enum_decl->getIntegerType();
+                        
+                        enum_decl->completeDefinition(enum_decl->getIntegerType(), promotion_qual_type, NumPositiveBits, NumNegativeBits);
                     }
-                    else
-                        promotion_qual_type = enum_decl->getIntegerType();
-                    
-                    enum_decl->completeDefinition(enum_decl->getIntegerType(), promotion_qual_type, NumPositiveBits, NumNegativeBits);
                 }
                 return true;
             }