Greg Clayton | 99558cc4 | 2015-08-24 23:46:31 +0000 | [diff] [blame] | 1 | //===-- CompilerDeclContext.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 "lldb/Symbol/CompilerDeclContext.h" |
Paul Herman | d628cbb | 2015-09-15 23:44:17 +0000 | [diff] [blame^] | 11 | #include "lldb/Symbol/CompilerDecl.h" |
Greg Clayton | 99558cc4 | 2015-08-24 23:46:31 +0000 | [diff] [blame] | 12 | #include "lldb/Symbol/TypeSystem.h" |
Paul Herman | d628cbb | 2015-09-15 23:44:17 +0000 | [diff] [blame^] | 13 | #include <vector> |
Greg Clayton | 99558cc4 | 2015-08-24 23:46:31 +0000 | [diff] [blame] | 14 | |
| 15 | using namespace lldb_private; |
| 16 | |
Paul Herman | d628cbb | 2015-09-15 23:44:17 +0000 | [diff] [blame^] | 17 | std::vector<CompilerDecl> |
| 18 | CompilerDeclContext::FindDeclByName (ConstString name) |
| 19 | { |
| 20 | std::vector<CompilerDecl> found_decls; |
| 21 | if (IsValid()) |
| 22 | { |
| 23 | std::vector<void *> found_opaque_decls = m_type_system->DeclContextFindDeclByName(m_opaque_decl_ctx, name); |
| 24 | for (void *opaque_decl : found_opaque_decls) |
| 25 | found_decls.push_back(CompilerDecl(m_type_system, opaque_decl)); |
| 26 | } |
| 27 | return found_decls; |
| 28 | } |
| 29 | |
Greg Clayton | 99558cc4 | 2015-08-24 23:46:31 +0000 | [diff] [blame] | 30 | bool |
| 31 | CompilerDeclContext::IsClang () const |
| 32 | { |
Greg Clayton | f73034f | 2015-09-08 18:15:05 +0000 | [diff] [blame] | 33 | return IsValid() && m_type_system->getKind() == TypeSystem::eKindClang; |
Greg Clayton | 99558cc4 | 2015-08-24 23:46:31 +0000 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | ConstString |
| 37 | CompilerDeclContext::GetName () const |
| 38 | { |
| 39 | if (IsValid()) |
| 40 | return m_type_system->DeclContextGetName(m_opaque_decl_ctx); |
| 41 | else |
| 42 | return ConstString(); |
| 43 | } |
| 44 | |
| 45 | bool |
| 46 | CompilerDeclContext::IsStructUnionOrClass () const |
| 47 | { |
| 48 | if (IsValid()) |
| 49 | return m_type_system->DeclContextIsStructUnionOrClass(m_opaque_decl_ctx); |
| 50 | else |
| 51 | return false; |
| 52 | } |
| 53 | |
| 54 | bool |
| 55 | CompilerDeclContext::IsClassMethod (lldb::LanguageType *language_ptr, |
| 56 | bool *is_instance_method_ptr, |
| 57 | ConstString *language_object_name_ptr) |
| 58 | { |
| 59 | if (IsValid()) |
| 60 | return m_type_system->DeclContextIsClassMethod (m_opaque_decl_ctx, |
| 61 | language_ptr, |
| 62 | is_instance_method_ptr, |
| 63 | language_object_name_ptr); |
| 64 | else |
| 65 | return false; |
| 66 | } |
| 67 | |
| 68 | bool |
| 69 | lldb_private::operator == (const lldb_private::CompilerDeclContext &lhs, const lldb_private::CompilerDeclContext &rhs) |
| 70 | { |
| 71 | return lhs.GetTypeSystem() == rhs.GetTypeSystem() && lhs.GetOpaqueDeclContext() == rhs.GetOpaqueDeclContext(); |
| 72 | } |
| 73 | |
| 74 | |
| 75 | bool |
| 76 | lldb_private::operator != (const lldb_private::CompilerDeclContext &lhs, const lldb_private::CompilerDeclContext &rhs) |
| 77 | { |
| 78 | return lhs.GetTypeSystem() != rhs.GetTypeSystem() || lhs.GetOpaqueDeclContext() != rhs.GetOpaqueDeclContext(); |
| 79 | } |