15ffd83dbSDimitry Andric //===-- CompilerDeclContext.cpp -------------------------------------------===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric 90b57cec5SDimitry Andric #include "lldb/Symbol/CompilerDeclContext.h" 100b57cec5SDimitry Andric #include "lldb/Symbol/CompilerDecl.h" 110b57cec5SDimitry Andric #include "lldb/Symbol/TypeSystem.h" 120b57cec5SDimitry Andric #include <vector> 130b57cec5SDimitry Andric 140b57cec5SDimitry Andric using namespace lldb_private; 150b57cec5SDimitry Andric 160b57cec5SDimitry Andric std::vector<CompilerDecl> 170b57cec5SDimitry Andric CompilerDeclContext::FindDeclByName(ConstString name, 180b57cec5SDimitry Andric const bool ignore_using_decls) { 190b57cec5SDimitry Andric if (IsValid()) 200b57cec5SDimitry Andric return m_type_system->DeclContextFindDeclByName(m_opaque_decl_ctx, name, 210b57cec5SDimitry Andric ignore_using_decls); 220b57cec5SDimitry Andric return std::vector<CompilerDecl>(); 230b57cec5SDimitry Andric } 240b57cec5SDimitry Andric 250b57cec5SDimitry Andric ConstString CompilerDeclContext::GetName() const { 260b57cec5SDimitry Andric if (IsValid()) 270b57cec5SDimitry Andric return m_type_system->DeclContextGetName(m_opaque_decl_ctx); 280b57cec5SDimitry Andric return ConstString(); 290b57cec5SDimitry Andric } 300b57cec5SDimitry Andric 310b57cec5SDimitry Andric ConstString CompilerDeclContext::GetScopeQualifiedName() const { 320b57cec5SDimitry Andric if (IsValid()) 330b57cec5SDimitry Andric return m_type_system->DeclContextGetScopeQualifiedName(m_opaque_decl_ctx); 340b57cec5SDimitry Andric return ConstString(); 350b57cec5SDimitry Andric } 360b57cec5SDimitry Andric 37*fe013be4SDimitry Andric bool CompilerDeclContext::IsClassMethod() { 380b57cec5SDimitry Andric if (IsValid()) 39*fe013be4SDimitry Andric return m_type_system->DeclContextIsClassMethod(m_opaque_decl_ctx); 400b57cec5SDimitry Andric return false; 410b57cec5SDimitry Andric } 420b57cec5SDimitry Andric 43*fe013be4SDimitry Andric lldb::LanguageType CompilerDeclContext::GetLanguage() { 44*fe013be4SDimitry Andric if (IsValid()) 45*fe013be4SDimitry Andric return m_type_system->DeclContextGetLanguage(m_opaque_decl_ctx); 46*fe013be4SDimitry Andric return {}; 47*fe013be4SDimitry Andric } 48*fe013be4SDimitry Andric 490b57cec5SDimitry Andric bool CompilerDeclContext::IsContainedInLookup(CompilerDeclContext other) const { 500b57cec5SDimitry Andric if (!IsValid()) 510b57cec5SDimitry Andric return false; 520b57cec5SDimitry Andric 530b57cec5SDimitry Andric // If the other context is just the current context, we don't need to go 540b57cec5SDimitry Andric // over the type system to know that the lookup is identical. 550b57cec5SDimitry Andric if (this == &other) 560b57cec5SDimitry Andric return true; 570b57cec5SDimitry Andric 580b57cec5SDimitry Andric return m_type_system->DeclContextIsContainedInLookup(m_opaque_decl_ctx, 590b57cec5SDimitry Andric other.m_opaque_decl_ctx); 600b57cec5SDimitry Andric } 610b57cec5SDimitry Andric 620b57cec5SDimitry Andric bool lldb_private::operator==(const lldb_private::CompilerDeclContext &lhs, 630b57cec5SDimitry Andric const lldb_private::CompilerDeclContext &rhs) { 640b57cec5SDimitry Andric return lhs.GetTypeSystem() == rhs.GetTypeSystem() && 650b57cec5SDimitry Andric lhs.GetOpaqueDeclContext() == rhs.GetOpaqueDeclContext(); 660b57cec5SDimitry Andric } 670b57cec5SDimitry Andric 680b57cec5SDimitry Andric bool lldb_private::operator!=(const lldb_private::CompilerDeclContext &lhs, 690b57cec5SDimitry Andric const lldb_private::CompilerDeclContext &rhs) { 700b57cec5SDimitry Andric return lhs.GetTypeSystem() != rhs.GetTypeSystem() || 710b57cec5SDimitry Andric lhs.GetOpaqueDeclContext() != rhs.GetOpaqueDeclContext(); 720b57cec5SDimitry Andric } 73