llvm-project/lldb/source/Symbol/ClangASTImporter.cpp
Greg Clayton dd0649bc5f Fixed an issue that was causing us to crash when evaluating expressions for
objective C or C++ methods when "self" or "this" were in scope, but had 
invalid locations in a DWARF location list. The lack of a valid value caused
us to use an invalid type value and then we tried to import that invalid 
value and we would crash.

llvm-svn: 134518
2011-07-06 18:55:08 +00:00

65 lines
1.8 KiB
C++

//===-- ClangASTImporter.cpp ------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "clang/AST/Decl.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ClangASTImporter.h"
using namespace lldb_private;
using namespace clang;
clang::QualType
ClangASTImporter::CopyType (clang::ASTContext *src_ast,
clang::QualType type)
{
MinionSP minion_sp (GetMinion(src_ast, false));
if (minion_sp)
return minion_sp->Import(type);
return QualType();
}
clang::Decl *
ClangASTImporter::CopyDecl (clang::ASTContext *src_ast,
clang::Decl *decl)
{
MinionSP minion_sp;
if (isa<clang::NamespaceDecl>(decl))
minion_sp = GetMinion(src_ast, true);
else
minion_sp = GetMinion(src_ast, false);
if (minion_sp)
return minion_sp->Import(decl);
return NULL;
}
const clang::DeclContext *
ClangASTImporter::CompleteDeclContext (const clang::DeclContext *decl_context)
{
const Decl *context_decl = dyn_cast<Decl>(decl_context);
if (!context_decl)
return NULL;
DeclOrigin context_decl_origin = GetDeclOrigin(context_decl);
if (!context_decl_origin.Valid())
return NULL;
if (!ClangASTContext::GetCompleteDecl(context_decl_origin.ctx, context_decl_origin.decl))
return NULL;
MinionSP minion_sp (GetMinion(context_decl_origin.ctx, false));
if (minion_sp)
minion_sp->ImportDefinition(context_decl_origin.decl);
return decl_context;
}