Don't crash if we load a file with an architecture we don't support and try to parse some DWARF.
The ClangASTContext::getTargetInfo() will return NULL in this case and could cause us to crash if we don't check.
<rdar://problem/20543554>
llvm-svn: 236681
diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp
index 8495e1e..3c3e2e5 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -403,8 +403,12 @@
*getBuiltinContext()));
m_ast_ap->getDiagnostics().setClient(getDiagnosticConsumer(), false);
-
- m_ast_ap->InitBuiltinTypes(*getTargetInfo());
+
+ // This can be NULL if we don't know anything about the architecture or if the
+ // target for an architecture isn't enabled in the llvm/clang that we built
+ TargetInfo *target_info = getTargetInfo();
+ if (target_info)
+ m_ast_ap->InitBuiltinTypes(*target_info);
if ((m_callback_tag_decl || m_callback_objc_decl) && m_callback_baton)
{
@@ -906,7 +910,7 @@
{
if (streq(type_name, "wchar_t") &&
QualTypeMatchesBitSize (bit_size, ast, ast->WCharTy) &&
- TargetInfo::isTypeSigned (getTargetInfo()->getWCharType()))
+ (getTargetInfo() && TargetInfo::isTypeSigned (getTargetInfo()->getWCharType())))
return ClangASTType (ast, ast->WCharTy.getAsOpaquePtr());
if (streq(type_name, "void") &&
QualTypeMatchesBitSize (bit_size, ast, ast->VoidTy))
@@ -967,7 +971,7 @@
{
if (QualTypeMatchesBitSize (bit_size, ast, ast->WCharTy))
{
- if (!TargetInfo::isTypeSigned (getTargetInfo()->getWCharType()))
+ if (!(getTargetInfo() && TargetInfo::isTypeSigned (getTargetInfo()->getWCharType())))
return ClangASTType (ast, ast->WCharTy.getAsOpaquePtr());
}
}