Fixed Variable::GetDecl() and Variable::GetDeclContext() to check the "Type *" before using it so we don't crash if a variable's type can't be realized which happens more often recently due to -gmodules.

<rdar://problem/25612626>

llvm-svn: 266023
This commit is contained in:
Greg Clayton 2016-04-12 00:06:27 +00:00
parent 4f43cfd2c2
commit a15942ff05
1 changed files with 10 additions and 4 deletions

View File

@ -244,16 +244,22 @@ CompilerDeclContext
Variable::GetDeclContext ()
{
Type *type = GetType();
return type->GetSymbolFile()->GetDeclContextContainingUID(GetID());
if (type)
return type->GetSymbolFile()->GetDeclContextContainingUID(GetID());
return CompilerDeclContext();
}
CompilerDecl
Variable::GetDecl ()
{
CompilerDecl decl;
Type *type = GetType();
CompilerDecl decl = type->GetSymbolFile()->GetDeclForUID(GetID());
if (decl)
decl.GetTypeSystem()->DeclLinkToObject(decl.GetOpaqueDecl(), shared_from_this());
if (type)
{
decl = type->GetSymbolFile()->GetDeclForUID(GetID());
if (decl)
decl.GetTypeSystem()->DeclLinkToObject(decl.GetOpaqueDecl(), shared_from_this());
}
return decl;
}