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
This commit is contained in:
parent
d528112b41
commit
28eb7bf406
|
@ -403,8 +403,12 @@ ClangASTContext::getASTContext()
|
||||||
*getBuiltinContext()));
|
*getBuiltinContext()));
|
||||||
|
|
||||||
m_ast_ap->getDiagnostics().setClient(getDiagnosticConsumer(), false);
|
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)
|
if ((m_callback_tag_decl || m_callback_objc_decl) && m_callback_baton)
|
||||||
{
|
{
|
||||||
|
@ -906,7 +910,7 @@ ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize (const char *type_name
|
||||||
{
|
{
|
||||||
if (streq(type_name, "wchar_t") &&
|
if (streq(type_name, "wchar_t") &&
|
||||||
QualTypeMatchesBitSize (bit_size, ast, ast->WCharTy) &&
|
QualTypeMatchesBitSize (bit_size, ast, ast->WCharTy) &&
|
||||||
TargetInfo::isTypeSigned (getTargetInfo()->getWCharType()))
|
(getTargetInfo() && TargetInfo::isTypeSigned (getTargetInfo()->getWCharType())))
|
||||||
return ClangASTType (ast, ast->WCharTy.getAsOpaquePtr());
|
return ClangASTType (ast, ast->WCharTy.getAsOpaquePtr());
|
||||||
if (streq(type_name, "void") &&
|
if (streq(type_name, "void") &&
|
||||||
QualTypeMatchesBitSize (bit_size, ast, ast->VoidTy))
|
QualTypeMatchesBitSize (bit_size, ast, ast->VoidTy))
|
||||||
|
@ -967,7 +971,7 @@ ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize (const char *type_name
|
||||||
{
|
{
|
||||||
if (QualTypeMatchesBitSize (bit_size, ast, ast->WCharTy))
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->WCharTy))
|
||||||
{
|
{
|
||||||
if (!TargetInfo::isTypeSigned (getTargetInfo()->getWCharType()))
|
if (!(getTargetInfo() && TargetInfo::isTypeSigned (getTargetInfo()->getWCharType())))
|
||||||
return ClangASTType (ast, ast->WCharTy.getAsOpaquePtr());
|
return ClangASTType (ast, ast->WCharTy.getAsOpaquePtr());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue