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 | { |
Paul Herman | d628cbb | 2015-09-15 23:44:17 +0000 | [diff] [blame] | 20 | if (IsValid()) |
Greg Clayton | dfc0962 | 2015-12-08 18:39:50 +0000 | [diff] [blame] | 21 | return m_type_system->DeclContextFindDeclByName(m_opaque_decl_ctx, name); |
| 22 | else |
| 23 | return std::vector<CompilerDecl>(); |
Paul Herman | d628cbb | 2015-09-15 23:44:17 +0000 | [diff] [blame] | 24 | } |
| 25 | |
Greg Clayton | 99558cc4 | 2015-08-24 23:46:31 +0000 | [diff] [blame] | 26 | bool |
| 27 | CompilerDeclContext::IsClang () const |
| 28 | { |
Greg Clayton | f73034f | 2015-09-08 18:15:05 +0000 | [diff] [blame] | 29 | return IsValid() && m_type_system->getKind() == TypeSystem::eKindClang; |
Greg Clayton | 99558cc4 | 2015-08-24 23:46:31 +0000 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | ConstString |
| 33 | CompilerDeclContext::GetName () const |
| 34 | { |
| 35 | if (IsValid()) |
| 36 | return m_type_system->DeclContextGetName(m_opaque_decl_ctx); |
| 37 | else |
| 38 | return ConstString(); |
| 39 | } |
| 40 | |
Siva Chandra | 9293fc4 | 2016-01-07 23:32:34 +0000 | [diff] [blame^] | 41 | ConstString |
| 42 | CompilerDeclContext::GetScopeQualifiedName () const |
| 43 | { |
| 44 | if (IsValid()) |
| 45 | return m_type_system->DeclContextGetScopeQualifiedName(m_opaque_decl_ctx); |
| 46 | else |
| 47 | return ConstString(); |
| 48 | } |
| 49 | |
Greg Clayton | 99558cc4 | 2015-08-24 23:46:31 +0000 | [diff] [blame] | 50 | bool |
| 51 | CompilerDeclContext::IsStructUnionOrClass () const |
| 52 | { |
| 53 | if (IsValid()) |
| 54 | return m_type_system->DeclContextIsStructUnionOrClass(m_opaque_decl_ctx); |
| 55 | else |
| 56 | return false; |
| 57 | } |
| 58 | |
| 59 | bool |
| 60 | CompilerDeclContext::IsClassMethod (lldb::LanguageType *language_ptr, |
| 61 | bool *is_instance_method_ptr, |
| 62 | ConstString *language_object_name_ptr) |
| 63 | { |
| 64 | if (IsValid()) |
| 65 | return m_type_system->DeclContextIsClassMethod (m_opaque_decl_ctx, |
| 66 | language_ptr, |
| 67 | is_instance_method_ptr, |
| 68 | language_object_name_ptr); |
| 69 | else |
| 70 | return false; |
| 71 | } |
| 72 | |
| 73 | bool |
| 74 | lldb_private::operator == (const lldb_private::CompilerDeclContext &lhs, const lldb_private::CompilerDeclContext &rhs) |
| 75 | { |
| 76 | return lhs.GetTypeSystem() == rhs.GetTypeSystem() && lhs.GetOpaqueDeclContext() == rhs.GetOpaqueDeclContext(); |
| 77 | } |
| 78 | |
| 79 | |
| 80 | bool |
| 81 | lldb_private::operator != (const lldb_private::CompilerDeclContext &lhs, const lldb_private::CompilerDeclContext &rhs) |
| 82 | { |
| 83 | return lhs.GetTypeSystem() != rhs.GetTypeSystem() || lhs.GetOpaqueDeclContext() != rhs.GetOpaqueDeclContext(); |
| 84 | } |