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