[Lldb-commits] [lldb] r236681 - Don't crash if we load a file with an architecture we don't support and try to parse some DWARF.
Greg Clayton
gclayton at apple.com
Wed May 6 17:07:44 PDT 2015
Author: gclayton
Date: Wed May 6 19:07:44 2015
New Revision: 236681
URL: http://llvm.org/viewvc/llvm-project?rev=236681&view=rev
Log:
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>
Modified:
lldb/trunk/source/Symbol/ClangASTContext.cpp
Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=236681&r1=236680&r2=236681&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Wed May 6 19:07:44 2015
@@ -403,8 +403,12 @@ ClangASTContext::getASTContext()
*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 @@ ClangASTContext::GetBuiltinTypeForDWARFE
{
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 @@ ClangASTContext::GetBuiltinTypeForDWARFE
{
if (QualTypeMatchesBitSize (bit_size, ast, ast->WCharTy))
{
- if (!TargetInfo::isTypeSigned (getTargetInfo()->getWCharType()))
+ if (!(getTargetInfo() && TargetInfo::isTypeSigned (getTargetInfo()->getWCharType())))
return ClangASTType (ast, ast->WCharTy.getAsOpaquePtr());
}
}
More information about the lldb-commits
mailing list