1292932Sdim//===-- CompilerDeclContext.cpp ---------------------------------*- C++ -*-===// 2292932Sdim// 3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4353358Sdim// See https://llvm.org/LICENSE.txt for license information. 5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6292932Sdim// 7292932Sdim//===----------------------------------------------------------------------===// 8292932Sdim 9292932Sdim#include "lldb/Symbol/CompilerDeclContext.h" 10292932Sdim#include "lldb/Symbol/CompilerDecl.h" 11292932Sdim#include "lldb/Symbol/TypeSystem.h" 12292932Sdim#include <vector> 13292932Sdim 14292932Sdimusing namespace lldb_private; 15292932Sdim 16292932Sdimstd::vector<CompilerDecl> 17314564SdimCompilerDeclContext::FindDeclByName(ConstString name, 18314564Sdim const bool ignore_using_decls) { 19314564Sdim if (IsValid()) 20314564Sdim return m_type_system->DeclContextFindDeclByName(m_opaque_decl_ctx, name, 21314564Sdim ignore_using_decls); 22360784Sdim return std::vector<CompilerDecl>(); 23292932Sdim} 24292932Sdim 25314564SdimConstString CompilerDeclContext::GetName() const { 26314564Sdim if (IsValid()) 27314564Sdim return m_type_system->DeclContextGetName(m_opaque_decl_ctx); 28360784Sdim return ConstString(); 29292932Sdim} 30292932Sdim 31314564SdimConstString CompilerDeclContext::GetScopeQualifiedName() const { 32314564Sdim if (IsValid()) 33314564Sdim return m_type_system->DeclContextGetScopeQualifiedName(m_opaque_decl_ctx); 34360784Sdim return ConstString(); 35294024Sdim} 36294024Sdim 37314564Sdimbool CompilerDeclContext::IsClassMethod(lldb::LanguageType *language_ptr, 38314564Sdim bool *is_instance_method_ptr, 39314564Sdim ConstString *language_object_name_ptr) { 40314564Sdim if (IsValid()) 41314564Sdim return m_type_system->DeclContextIsClassMethod( 42314564Sdim m_opaque_decl_ctx, language_ptr, is_instance_method_ptr, 43314564Sdim language_object_name_ptr); 44360784Sdim return false; 45292932Sdim} 46292932Sdim 47353358Sdimbool CompilerDeclContext::IsContainedInLookup(CompilerDeclContext other) const { 48353358Sdim if (!IsValid()) 49353358Sdim return false; 50353358Sdim 51353358Sdim // If the other context is just the current context, we don't need to go 52353358Sdim // over the type system to know that the lookup is identical. 53353358Sdim if (this == &other) 54353358Sdim return true; 55353358Sdim 56353358Sdim return m_type_system->DeclContextIsContainedInLookup(m_opaque_decl_ctx, 57353358Sdim other.m_opaque_decl_ctx); 58353358Sdim} 59353358Sdim 60314564Sdimbool lldb_private::operator==(const lldb_private::CompilerDeclContext &lhs, 61314564Sdim const lldb_private::CompilerDeclContext &rhs) { 62314564Sdim return lhs.GetTypeSystem() == rhs.GetTypeSystem() && 63314564Sdim lhs.GetOpaqueDeclContext() == rhs.GetOpaqueDeclContext(); 64292932Sdim} 65292932Sdim 66314564Sdimbool lldb_private::operator!=(const lldb_private::CompilerDeclContext &lhs, 67314564Sdim const lldb_private::CompilerDeclContext &rhs) { 68314564Sdim return lhs.GetTypeSystem() != rhs.GetTypeSystem() || 69314564Sdim lhs.GetOpaqueDeclContext() != rhs.GetOpaqueDeclContext(); 70292932Sdim} 71