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