Greg Clayton | a272147 | 2011-06-25 00:44:06 +0000 | [diff] [blame] | 1 | //===-- ClangASTImporter.cpp ------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "clang/AST/Decl.h" |
| 11 | #include "lldb/Symbol/ClangASTContext.h" |
| 12 | #include "lldb/Symbol/ClangASTImporter.h" |
| 13 | |
| 14 | using namespace lldb_private; |
| 15 | using namespace clang; |
| 16 | |
| 17 | clang::QualType |
| 18 | ClangASTImporter::CopyType (clang::ASTContext *src_ast, |
| 19 | clang::QualType type) |
| 20 | { |
Greg Clayton | dd0649b | 2011-07-06 18:55:08 +0000 | [diff] [blame^] | 21 | MinionSP minion_sp (GetMinion(src_ast, false)); |
| 22 | if (minion_sp) |
| 23 | return minion_sp->Import(type); |
| 24 | return QualType(); |
Greg Clayton | a272147 | 2011-06-25 00:44:06 +0000 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | clang::Decl * |
| 28 | ClangASTImporter::CopyDecl (clang::ASTContext *src_ast, |
| 29 | clang::Decl *decl) |
| 30 | { |
Greg Clayton | dd0649b | 2011-07-06 18:55:08 +0000 | [diff] [blame^] | 31 | MinionSP minion_sp; |
Greg Clayton | a272147 | 2011-06-25 00:44:06 +0000 | [diff] [blame] | 32 | |
| 33 | if (isa<clang::NamespaceDecl>(decl)) |
Greg Clayton | dd0649b | 2011-07-06 18:55:08 +0000 | [diff] [blame^] | 34 | minion_sp = GetMinion(src_ast, true); |
Greg Clayton | a272147 | 2011-06-25 00:44:06 +0000 | [diff] [blame] | 35 | else |
Greg Clayton | dd0649b | 2011-07-06 18:55:08 +0000 | [diff] [blame^] | 36 | minion_sp = GetMinion(src_ast, false); |
Greg Clayton | a272147 | 2011-06-25 00:44:06 +0000 | [diff] [blame] | 37 | |
Greg Clayton | dd0649b | 2011-07-06 18:55:08 +0000 | [diff] [blame^] | 38 | if (minion_sp) |
| 39 | return minion_sp->Import(decl); |
| 40 | return NULL; |
Greg Clayton | a272147 | 2011-06-25 00:44:06 +0000 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | const clang::DeclContext * |
| 44 | ClangASTImporter::CompleteDeclContext (const clang::DeclContext *decl_context) |
| 45 | { |
| 46 | const Decl *context_decl = dyn_cast<Decl>(decl_context); |
| 47 | |
| 48 | if (!context_decl) |
| 49 | return NULL; |
| 50 | |
| 51 | DeclOrigin context_decl_origin = GetDeclOrigin(context_decl); |
| 52 | |
| 53 | if (!context_decl_origin.Valid()) |
| 54 | return NULL; |
| 55 | |
| 56 | if (!ClangASTContext::GetCompleteDecl(context_decl_origin.ctx, context_decl_origin.decl)) |
| 57 | return NULL; |
| 58 | |
Greg Clayton | dd0649b | 2011-07-06 18:55:08 +0000 | [diff] [blame^] | 59 | MinionSP minion_sp (GetMinion(context_decl_origin.ctx, false)); |
| 60 | if (minion_sp) |
| 61 | minion_sp->ImportDefinition(context_decl_origin.decl); |
Greg Clayton | a272147 | 2011-06-25 00:44:06 +0000 | [diff] [blame] | 62 | |
| 63 | return decl_context; |
| 64 | } |