forked from OSchip/llvm-project
Modified clients of ClangASTImporter to be more robust
in the face of failures to import types, since blithely passing on NULL types can sometimes lead to trouble. Also eliminated a use of getAs and replaced it with dyn_cast, which is more robust. llvm-svn: 145628
This commit is contained in:
parent
54c9462c77
commit
e0a64f7302
|
@ -503,6 +503,14 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context,
|
|||
|
||||
void *copied_type = GuardedCopyType(m_ast_context, type_sp->GetClangAST(), type_sp->GetClangFullType());
|
||||
|
||||
if (!copied_type)
|
||||
{
|
||||
if (log)
|
||||
log->Printf("ClangExpressionDeclMap::BuildIntegerVariable - Couldn't export the type for a constant integer result");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
context.AddTypeDecl(copied_type);
|
||||
}
|
||||
|
||||
|
@ -845,7 +853,7 @@ NameSearchContext::AddFunDecl (void *type)
|
|||
// this, we raid the function's FunctionProtoType for types.
|
||||
|
||||
QualType qual_type (QualType::getFromOpaquePtr(type));
|
||||
const FunctionProtoType *func_proto_type = qual_type->getAs<FunctionProtoType>();
|
||||
const FunctionProtoType *func_proto_type = dyn_cast<FunctionProtoType>(qual_type.getTypePtr());
|
||||
|
||||
if (func_proto_type)
|
||||
{
|
||||
|
@ -872,6 +880,12 @@ NameSearchContext::AddFunDecl (void *type)
|
|||
|
||||
func_decl->setParams(ArrayRef<ParmVarDecl*>(parm_var_decls));
|
||||
}
|
||||
else
|
||||
{
|
||||
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
||||
|
||||
log->Printf("Function type wasn't a FunctionProtoType");
|
||||
}
|
||||
|
||||
m_decls.push_back(func_decl);
|
||||
|
||||
|
|
|
@ -201,6 +201,16 @@ ClangExpressionDeclMap::BuildIntegerVariable (const ConstString &name,
|
|||
type.GetOpaqueQualType()),
|
||||
context);
|
||||
|
||||
if (!user_type.GetOpaqueQualType())
|
||||
{
|
||||
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
||||
|
||||
if (log)
|
||||
log->Printf("ClangExpressionDeclMap::BuildIntegerVariable - Couldn't export the type for a constant integer result");
|
||||
|
||||
return lldb::ClangExpressionVariableSP();
|
||||
}
|
||||
|
||||
if (!m_parser_vars->m_persistent_vars->CreatePersistentVariable (exe_ctx->GetBestExecutionContextScope (),
|
||||
name,
|
||||
user_type,
|
||||
|
@ -290,6 +300,16 @@ ClangExpressionDeclMap::BuildCastVariable (const ConstString &name,
|
|||
type.GetOpaqueQualType()),
|
||||
context);
|
||||
|
||||
if (!user_type.GetOpaqueQualType())
|
||||
{
|
||||
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
||||
|
||||
if (log)
|
||||
log->Printf("ClangExpressionDeclMap::BuildCastVariable - Couldn't export the type for a constant cast result");
|
||||
|
||||
return lldb::ClangExpressionVariableSP();
|
||||
}
|
||||
|
||||
TypeFromUser var_type = var_sp->GetTypeFromUser();
|
||||
|
||||
StackFrame *frame = exe_ctx->GetFramePtr();
|
||||
|
@ -2793,6 +2813,13 @@ ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
|
|||
user_type.GetOpaqueQualType()),
|
||||
m_ast_context);
|
||||
|
||||
if (!parser_type.GetOpaqueQualType())
|
||||
{
|
||||
if (log)
|
||||
log->Printf(" CEDM::FEVD[%u] Couldn't import type for pvar %s", current_id, pvar_sp->GetName().GetCString());
|
||||
return;
|
||||
}
|
||||
|
||||
NamedDecl *var_decl = context.AddVarDecl(ClangASTContext::CreateLValueReferenceType(parser_type.GetASTContext(), parser_type.GetOpaqueQualType()));
|
||||
|
||||
pvar_sp->EnableParserVars();
|
||||
|
@ -2903,6 +2930,14 @@ ClangExpressionDeclMap::ResolveUnknownTypes()
|
|||
|
||||
lldb::clang_type_t copied_type = m_ast_importer->CopyType(scratch_ast_context, &var_decl->getASTContext(), var_type.getAsOpaquePtr());
|
||||
|
||||
if (!copied_type)
|
||||
{
|
||||
if (log)
|
||||
log->Printf("ClangExpressionDeclMap::ResolveUnknownType - Couldn't import the type for a variable");
|
||||
|
||||
return lldb::ClangExpressionVariableSP();
|
||||
}
|
||||
|
||||
TypeFromUser user_type(copied_type, scratch_ast_context);
|
||||
|
||||
entity->m_parser_vars->m_lldb_value->SetContext(Value::eContextTypeClangType, user_type.GetOpaqueQualType());
|
||||
|
@ -3075,6 +3110,16 @@ ClangExpressionDeclMap::AddOneType(NameSearchContext &context,
|
|||
ASTContext *user_ast_context = ut.GetASTContext();
|
||||
|
||||
void *copied_type = GuardedCopyType(parser_ast_context, user_ast_context, ut.GetOpaqueQualType());
|
||||
|
||||
if (!copied_type)
|
||||
{
|
||||
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
||||
|
||||
if (log)
|
||||
log->Printf("ClangExpressionDeclMap::AddOneType - Couldn't import the type");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (add_method && ClangASTContext::IsAggregateType(copied_type))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue