From a15942ff051e378d5af5f399a827ad1051112c21 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Tue, 12 Apr 2016 00:06:27 +0000 Subject: [PATCH] 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. llvm-svn: 266023 --- lldb/source/Symbol/Variable.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp index 47f573d..29fe4bb 100644 --- a/lldb/source/Symbol/Variable.cpp +++ b/lldb/source/Symbol/Variable.cpp @@ -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; } -- 2.7.4