1*dda28197Spatrick //===-- CompilerDeclContext.cpp -------------------------------------------===//
2061da546Spatrick //
3061da546Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4061da546Spatrick // See https://llvm.org/LICENSE.txt for license information.
5061da546Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6061da546Spatrick //
7061da546Spatrick //===----------------------------------------------------------------------===//
8061da546Spatrick 
9061da546Spatrick #include "lldb/Symbol/CompilerDeclContext.h"
10061da546Spatrick #include "lldb/Symbol/CompilerDecl.h"
11061da546Spatrick #include "lldb/Symbol/TypeSystem.h"
12061da546Spatrick #include <vector>
13061da546Spatrick 
14061da546Spatrick using namespace lldb_private;
15061da546Spatrick 
16061da546Spatrick std::vector<CompilerDecl>
FindDeclByName(ConstString name,const bool ignore_using_decls)17061da546Spatrick CompilerDeclContext::FindDeclByName(ConstString name,
18061da546Spatrick                                     const bool ignore_using_decls) {
19061da546Spatrick   if (IsValid())
20061da546Spatrick     return m_type_system->DeclContextFindDeclByName(m_opaque_decl_ctx, name,
21061da546Spatrick                                                     ignore_using_decls);
22061da546Spatrick   return std::vector<CompilerDecl>();
23061da546Spatrick }
24061da546Spatrick 
GetName() const25061da546Spatrick ConstString CompilerDeclContext::GetName() const {
26061da546Spatrick   if (IsValid())
27061da546Spatrick     return m_type_system->DeclContextGetName(m_opaque_decl_ctx);
28061da546Spatrick   return ConstString();
29061da546Spatrick }
30061da546Spatrick 
GetScopeQualifiedName() const31061da546Spatrick ConstString CompilerDeclContext::GetScopeQualifiedName() const {
32061da546Spatrick   if (IsValid())
33061da546Spatrick     return m_type_system->DeclContextGetScopeQualifiedName(m_opaque_decl_ctx);
34061da546Spatrick   return ConstString();
35061da546Spatrick }
36061da546Spatrick 
IsClassMethod(lldb::LanguageType * language_ptr,bool * is_instance_method_ptr,ConstString * language_object_name_ptr)37061da546Spatrick bool CompilerDeclContext::IsClassMethod(lldb::LanguageType *language_ptr,
38061da546Spatrick                                         bool *is_instance_method_ptr,
39061da546Spatrick                                         ConstString *language_object_name_ptr) {
40061da546Spatrick   if (IsValid())
41061da546Spatrick     return m_type_system->DeclContextIsClassMethod(
42061da546Spatrick         m_opaque_decl_ctx, language_ptr, is_instance_method_ptr,
43061da546Spatrick         language_object_name_ptr);
44061da546Spatrick   return false;
45061da546Spatrick }
46061da546Spatrick 
IsContainedInLookup(CompilerDeclContext other) const47061da546Spatrick bool CompilerDeclContext::IsContainedInLookup(CompilerDeclContext other) const {
48061da546Spatrick   if (!IsValid())
49061da546Spatrick     return false;
50061da546Spatrick 
51061da546Spatrick   // If the other context is just the current context, we don't need to go
52061da546Spatrick   // over the type system to know that the lookup is identical.
53061da546Spatrick   if (this == &other)
54061da546Spatrick     return true;
55061da546Spatrick 
56061da546Spatrick   return m_type_system->DeclContextIsContainedInLookup(m_opaque_decl_ctx,
57061da546Spatrick                                                        other.m_opaque_decl_ctx);
58061da546Spatrick }
59061da546Spatrick 
operator ==(const lldb_private::CompilerDeclContext & lhs,const lldb_private::CompilerDeclContext & rhs)60061da546Spatrick bool lldb_private::operator==(const lldb_private::CompilerDeclContext &lhs,
61061da546Spatrick                               const lldb_private::CompilerDeclContext &rhs) {
62061da546Spatrick   return lhs.GetTypeSystem() == rhs.GetTypeSystem() &&
63061da546Spatrick          lhs.GetOpaqueDeclContext() == rhs.GetOpaqueDeclContext();
64061da546Spatrick }
65061da546Spatrick 
operator !=(const lldb_private::CompilerDeclContext & lhs,const lldb_private::CompilerDeclContext & rhs)66061da546Spatrick bool lldb_private::operator!=(const lldb_private::CompilerDeclContext &lhs,
67061da546Spatrick                               const lldb_private::CompilerDeclContext &rhs) {
68061da546Spatrick   return lhs.GetTypeSystem() != rhs.GetTypeSystem() ||
69061da546Spatrick          lhs.GetOpaqueDeclContext() != rhs.GetOpaqueDeclContext();
70061da546Spatrick }
71