15ffd83dbSDimitry Andric //===-- CompilerDeclContext.cpp -------------------------------------------===// 2*0b57cec5SDimitry Andric // 3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0b57cec5SDimitry Andric // 7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 8*0b57cec5SDimitry Andric 9*0b57cec5SDimitry Andric #include "lldb/Symbol/CompilerDeclContext.h" 10*0b57cec5SDimitry Andric #include "lldb/Symbol/CompilerDecl.h" 11*0b57cec5SDimitry Andric #include "lldb/Symbol/TypeSystem.h" 12*0b57cec5SDimitry Andric #include <vector> 13*0b57cec5SDimitry Andric 14*0b57cec5SDimitry Andric using namespace lldb_private; 15*0b57cec5SDimitry Andric 16*0b57cec5SDimitry Andric std::vector<CompilerDecl> 17*0b57cec5SDimitry Andric CompilerDeclContext::FindDeclByName(ConstString name, 18*0b57cec5SDimitry Andric const bool ignore_using_decls) { 19*0b57cec5SDimitry Andric if (IsValid()) 20*0b57cec5SDimitry Andric return m_type_system->DeclContextFindDeclByName(m_opaque_decl_ctx, name, 21*0b57cec5SDimitry Andric ignore_using_decls); 22*0b57cec5SDimitry Andric return std::vector<CompilerDecl>(); 23*0b57cec5SDimitry Andric } 24*0b57cec5SDimitry Andric 25*0b57cec5SDimitry Andric ConstString CompilerDeclContext::GetName() const { 26*0b57cec5SDimitry Andric if (IsValid()) 27*0b57cec5SDimitry Andric return m_type_system->DeclContextGetName(m_opaque_decl_ctx); 28*0b57cec5SDimitry Andric return ConstString(); 29*0b57cec5SDimitry Andric } 30*0b57cec5SDimitry Andric 31*0b57cec5SDimitry Andric ConstString CompilerDeclContext::GetScopeQualifiedName() const { 32*0b57cec5SDimitry Andric if (IsValid()) 33*0b57cec5SDimitry Andric return m_type_system->DeclContextGetScopeQualifiedName(m_opaque_decl_ctx); 34*0b57cec5SDimitry Andric return ConstString(); 35*0b57cec5SDimitry Andric } 36*0b57cec5SDimitry Andric 37*0b57cec5SDimitry Andric bool CompilerDeclContext::IsClassMethod(lldb::LanguageType *language_ptr, 38*0b57cec5SDimitry Andric bool *is_instance_method_ptr, 39*0b57cec5SDimitry Andric ConstString *language_object_name_ptr) { 40*0b57cec5SDimitry Andric if (IsValid()) 41*0b57cec5SDimitry Andric return m_type_system->DeclContextIsClassMethod( 42*0b57cec5SDimitry Andric m_opaque_decl_ctx, language_ptr, is_instance_method_ptr, 43*0b57cec5SDimitry Andric language_object_name_ptr); 44*0b57cec5SDimitry Andric return false; 45*0b57cec5SDimitry Andric } 46*0b57cec5SDimitry Andric 47*0b57cec5SDimitry Andric bool CompilerDeclContext::IsContainedInLookup(CompilerDeclContext other) const { 48*0b57cec5SDimitry Andric if (!IsValid()) 49*0b57cec5SDimitry Andric return false; 50*0b57cec5SDimitry Andric 51*0b57cec5SDimitry Andric // If the other context is just the current context, we don't need to go 52*0b57cec5SDimitry Andric // over the type system to know that the lookup is identical. 53*0b57cec5SDimitry Andric if (this == &other) 54*0b57cec5SDimitry Andric return true; 55*0b57cec5SDimitry Andric 56*0b57cec5SDimitry Andric return m_type_system->DeclContextIsContainedInLookup(m_opaque_decl_ctx, 57*0b57cec5SDimitry Andric other.m_opaque_decl_ctx); 58*0b57cec5SDimitry Andric } 59*0b57cec5SDimitry Andric 60*0b57cec5SDimitry Andric bool lldb_private::operator==(const lldb_private::CompilerDeclContext &lhs, 61*0b57cec5SDimitry Andric const lldb_private::CompilerDeclContext &rhs) { 62*0b57cec5SDimitry Andric return lhs.GetTypeSystem() == rhs.GetTypeSystem() && 63*0b57cec5SDimitry Andric lhs.GetOpaqueDeclContext() == rhs.GetOpaqueDeclContext(); 64*0b57cec5SDimitry Andric } 65*0b57cec5SDimitry Andric 66*0b57cec5SDimitry Andric bool lldb_private::operator!=(const lldb_private::CompilerDeclContext &lhs, 67*0b57cec5SDimitry Andric const lldb_private::CompilerDeclContext &rhs) { 68*0b57cec5SDimitry Andric return lhs.GetTypeSystem() != rhs.GetTypeSystem() || 69*0b57cec5SDimitry Andric lhs.GetOpaqueDeclContext() != rhs.GetOpaqueDeclContext(); 70*0b57cec5SDimitry Andric } 71