2011-06-25 08:44:06 +08:00
|
|
|
//===-- 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"
|
2011-07-30 10:42:06 +08:00
|
|
|
#include "clang/AST/DeclObjC.h"
|
|
|
|
#include "lldb/Core/Log.h"
|
2011-06-25 08:44:06 +08:00
|
|
|
#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)
|
|
|
|
{
|
2011-07-07 02:55:08 +08:00
|
|
|
MinionSP minion_sp (GetMinion(src_ast, false));
|
2011-07-30 10:42:06 +08:00
|
|
|
|
2011-07-07 02:55:08 +08:00
|
|
|
if (minion_sp)
|
|
|
|
return minion_sp->Import(type);
|
2011-07-30 10:42:06 +08:00
|
|
|
|
2011-07-07 02:55:08 +08:00
|
|
|
return QualType();
|
2011-06-25 08:44:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
clang::Decl *
|
|
|
|
ClangASTImporter::CopyDecl (clang::ASTContext *src_ast,
|
|
|
|
clang::Decl *decl)
|
|
|
|
{
|
2011-07-07 02:55:08 +08:00
|
|
|
MinionSP minion_sp;
|
2011-06-25 08:44:06 +08:00
|
|
|
|
|
|
|
if (isa<clang::NamespaceDecl>(decl))
|
2011-07-07 02:55:08 +08:00
|
|
|
minion_sp = GetMinion(src_ast, true);
|
2011-06-25 08:44:06 +08:00
|
|
|
else
|
2011-07-07 02:55:08 +08:00
|
|
|
minion_sp = GetMinion(src_ast, false);
|
2011-06-25 08:44:06 +08:00
|
|
|
|
2011-07-07 02:55:08 +08:00
|
|
|
if (minion_sp)
|
|
|
|
return minion_sp->Import(decl);
|
2011-07-30 10:42:06 +08:00
|
|
|
|
2011-07-07 02:55:08 +08:00
|
|
|
return NULL;
|
2011-06-25 08:44:06 +08:00
|
|
|
}
|
|
|
|
|
2011-07-30 10:42:06 +08:00
|
|
|
void
|
|
|
|
ClangASTImporter::CompleteTagDecl (clang::TagDecl *decl)
|
|
|
|
{
|
|
|
|
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
|
|
|
|
|
|
|
if (log)
|
|
|
|
log->Printf("Completing a TagDecl named %s", decl->getName().str().c_str());
|
|
|
|
|
|
|
|
DeclOrigin decl_origin = GetDeclOrigin(decl);
|
|
|
|
|
|
|
|
if (!decl_origin.Valid())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!ClangASTContext::GetCompleteDecl(decl_origin.ctx, decl_origin.decl))
|
|
|
|
return;
|
|
|
|
|
|
|
|
MinionSP minion_sp (GetMinion(decl_origin.ctx, false));
|
|
|
|
|
|
|
|
if (minion_sp)
|
|
|
|
minion_sp->ImportDefinition(decl_origin.decl);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ClangASTImporter::CompleteObjCInterfaceDecl (clang::ObjCInterfaceDecl *interface_decl)
|
2011-06-25 08:44:06 +08:00
|
|
|
{
|
2011-07-30 10:42:06 +08:00
|
|
|
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
|
|
|
|
|
|
|
if (log)
|
|
|
|
log->Printf("Completing an ObjCInterfaceDecl named %s", interface_decl->getName().str().c_str());
|
2011-06-25 08:44:06 +08:00
|
|
|
|
2011-07-30 10:42:06 +08:00
|
|
|
DeclOrigin decl_origin = GetDeclOrigin(interface_decl);
|
2011-06-25 08:44:06 +08:00
|
|
|
|
2011-07-30 10:42:06 +08:00
|
|
|
if (!decl_origin.Valid())
|
|
|
|
return;
|
2011-06-25 08:44:06 +08:00
|
|
|
|
2011-07-30 10:42:06 +08:00
|
|
|
if (!ClangASTContext::GetCompleteDecl(decl_origin.ctx, decl_origin.decl))
|
|
|
|
return;
|
2011-06-25 08:44:06 +08:00
|
|
|
|
2011-07-30 10:42:06 +08:00
|
|
|
MinionSP minion_sp (GetMinion(decl_origin.ctx, false));
|
2011-06-25 08:44:06 +08:00
|
|
|
|
2011-07-07 02:55:08 +08:00
|
|
|
if (minion_sp)
|
2011-07-30 10:42:06 +08:00
|
|
|
minion_sp->ImportDefinition(decl_origin.decl);
|
2011-06-25 08:44:06 +08:00
|
|
|
|
2011-07-30 10:42:06 +08:00
|
|
|
return;
|
2011-06-25 08:44:06 +08:00
|
|
|
}
|
2011-07-30 10:42:06 +08:00
|
|
|
|
|
|
|
clang::Decl
|
|
|
|
*ClangASTImporter::Minion::Imported (clang::Decl *from, clang::Decl *to)
|
|
|
|
{
|
|
|
|
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
|
|
|
|
|
|
|
m_master.m_origins[to] = DeclOrigin (m_source_ctx, from);
|
|
|
|
|
|
|
|
if (TagDecl *from_tag_decl = dyn_cast<TagDecl>(from))
|
|
|
|
{
|
|
|
|
TagDecl *to_tag_decl = dyn_cast<TagDecl>(to);
|
|
|
|
|
|
|
|
to_tag_decl->setHasExternalLexicalStorage();
|
|
|
|
|
|
|
|
if (log)
|
|
|
|
log->Printf("Imported a TagDecl named %s%s%s",
|
|
|
|
from_tag_decl->getName().str().c_str(),
|
|
|
|
(to_tag_decl->hasExternalLexicalStorage() ? " Lexical" : ""),
|
|
|
|
(to_tag_decl->hasExternalVisibleStorage() ? " Visible" : ""));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isa<ObjCInterfaceDecl>(from))
|
|
|
|
{
|
|
|
|
ObjCInterfaceDecl *to_interface_decl = dyn_cast<ObjCInterfaceDecl>(to);
|
|
|
|
|
|
|
|
to_interface_decl->setExternallyCompleted();
|
|
|
|
}
|
|
|
|
|
|
|
|
return clang::ASTImporter::Imported(from, to);
|
|
|
|
}
|