1*80814287SRaphael Isemann //===-- CompilerDeclContext.cpp -------------------------------------------===//
299558cc4SGreg Clayton //
32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
699558cc4SGreg Clayton //
799558cc4SGreg Clayton //===----------------------------------------------------------------------===//
899558cc4SGreg Clayton 
999558cc4SGreg Clayton #include "lldb/Symbol/CompilerDeclContext.h"
10d628cbb9SPaul Herman #include "lldb/Symbol/CompilerDecl.h"
1199558cc4SGreg Clayton #include "lldb/Symbol/TypeSystem.h"
12d628cbb9SPaul Herman #include <vector>
1399558cc4SGreg Clayton 
1499558cc4SGreg Clayton using namespace lldb_private;
1599558cc4SGreg Clayton 
16d628cbb9SPaul Herman std::vector<CompilerDecl>
FindDeclByName(ConstString name,const bool ignore_using_decls)17b9c1b51eSKate Stone CompilerDeclContext::FindDeclByName(ConstString name,
18b9c1b51eSKate Stone                                     const bool ignore_using_decls) {
19d628cbb9SPaul Herman   if (IsValid())
20b9c1b51eSKate Stone     return m_type_system->DeclContextFindDeclByName(m_opaque_decl_ctx, name,
21b9c1b51eSKate Stone                                                     ignore_using_decls);
22dfc09621SGreg Clayton   return std::vector<CompilerDecl>();
23d628cbb9SPaul Herman }
24d628cbb9SPaul Herman 
GetName() const25b9c1b51eSKate Stone ConstString CompilerDeclContext::GetName() const {
2699558cc4SGreg Clayton   if (IsValid())
2799558cc4SGreg Clayton     return m_type_system->DeclContextGetName(m_opaque_decl_ctx);
2899558cc4SGreg Clayton   return ConstString();
2999558cc4SGreg Clayton }
3099558cc4SGreg Clayton 
GetScopeQualifiedName() const31b9c1b51eSKate Stone ConstString CompilerDeclContext::GetScopeQualifiedName() const {
329293fc41SSiva Chandra   if (IsValid())
339293fc41SSiva Chandra     return m_type_system->DeclContextGetScopeQualifiedName(m_opaque_decl_ctx);
349293fc41SSiva Chandra   return ConstString();
359293fc41SSiva Chandra }
369293fc41SSiva Chandra 
IsClassMethod(lldb::LanguageType * language_ptr,bool * is_instance_method_ptr,ConstString * language_object_name_ptr)37b9c1b51eSKate Stone bool CompilerDeclContext::IsClassMethod(lldb::LanguageType *language_ptr,
3899558cc4SGreg Clayton                                         bool *is_instance_method_ptr,
39b9c1b51eSKate Stone                                         ConstString *language_object_name_ptr) {
4099558cc4SGreg Clayton   if (IsValid())
41b9c1b51eSKate Stone     return m_type_system->DeclContextIsClassMethod(
42b9c1b51eSKate Stone         m_opaque_decl_ctx, language_ptr, is_instance_method_ptr,
4399558cc4SGreg Clayton         language_object_name_ptr);
4499558cc4SGreg Clayton   return false;
4599558cc4SGreg Clayton }
4699558cc4SGreg Clayton 
IsContainedInLookup(CompilerDeclContext other) const47a946997cSRaphael Isemann bool CompilerDeclContext::IsContainedInLookup(CompilerDeclContext other) const {
48a946997cSRaphael Isemann   if (!IsValid())
49a946997cSRaphael Isemann     return false;
50a946997cSRaphael Isemann 
51a946997cSRaphael Isemann   // If the other context is just the current context, we don't need to go
52a946997cSRaphael Isemann   // over the type system to know that the lookup is identical.
53a946997cSRaphael Isemann   if (this == &other)
54a946997cSRaphael Isemann     return true;
55a946997cSRaphael Isemann 
56a946997cSRaphael Isemann   return m_type_system->DeclContextIsContainedInLookup(m_opaque_decl_ctx,
57a946997cSRaphael Isemann                                                        other.m_opaque_decl_ctx);
58a946997cSRaphael Isemann }
59a946997cSRaphael Isemann 
operator ==(const lldb_private::CompilerDeclContext & lhs,const lldb_private::CompilerDeclContext & rhs)60b9c1b51eSKate Stone bool lldb_private::operator==(const lldb_private::CompilerDeclContext &lhs,
61b9c1b51eSKate Stone                               const lldb_private::CompilerDeclContext &rhs) {
62b9c1b51eSKate Stone   return lhs.GetTypeSystem() == rhs.GetTypeSystem() &&
63b9c1b51eSKate Stone          lhs.GetOpaqueDeclContext() == rhs.GetOpaqueDeclContext();
6499558cc4SGreg Clayton }
6599558cc4SGreg Clayton 
operator !=(const lldb_private::CompilerDeclContext & lhs,const lldb_private::CompilerDeclContext & rhs)66b9c1b51eSKate Stone bool lldb_private::operator!=(const lldb_private::CompilerDeclContext &lhs,
67b9c1b51eSKate Stone                               const lldb_private::CompilerDeclContext &rhs) {
68b9c1b51eSKate Stone   return lhs.GetTypeSystem() != rhs.GetTypeSystem() ||
69b9c1b51eSKate Stone          lhs.GetOpaqueDeclContext() != rhs.GetOpaqueDeclContext();
7099558cc4SGreg Clayton }
71