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> |
17 | CompilerDeclContext::FindDeclByName(ConstString name, |
18 | const bool ignore_using_decls) { |
19 | if (IsValid()) |
20 | return m_type_system->DeclContextFindDeclByName(opaque_decl_ctx: m_opaque_decl_ctx, name, |
21 | ignore_imported_decls: ignore_using_decls); |
22 | return std::vector<CompilerDecl>(); |
23 | } |
24 | |
25 | ConstString CompilerDeclContext::GetName() const { |
26 | if (IsValid()) |
27 | return m_type_system->DeclContextGetName(opaque_decl_ctx: m_opaque_decl_ctx); |
28 | return ConstString(); |
29 | } |
30 | |
31 | ConstString CompilerDeclContext::GetScopeQualifiedName() const { |
32 | if (IsValid()) |
33 | return m_type_system->DeclContextGetScopeQualifiedName(opaque_decl_ctx: m_opaque_decl_ctx); |
34 | return ConstString(); |
35 | } |
36 | |
37 | bool CompilerDeclContext::IsClassMethod() { |
38 | if (IsValid()) |
39 | return m_type_system->DeclContextIsClassMethod(opaque_decl_ctx: m_opaque_decl_ctx); |
40 | return false; |
41 | } |
42 | |
43 | lldb::LanguageType CompilerDeclContext::GetLanguage() { |
44 | if (IsValid()) |
45 | return m_type_system->DeclContextGetLanguage(opaque_decl_ctx: m_opaque_decl_ctx); |
46 | return {}; |
47 | } |
48 | |
49 | bool CompilerDeclContext::IsContainedInLookup(CompilerDeclContext other) const { |
50 | if (!IsValid()) |
51 | return false; |
52 | |
53 | // If the other context is just the current context, we don't need to go |
54 | // over the type system to know that the lookup is identical. |
55 | if (this == &other) |
56 | return true; |
57 | |
58 | return m_type_system->DeclContextIsContainedInLookup(opaque_decl_ctx: m_opaque_decl_ctx, |
59 | other_opaque_decl_ctx: other.m_opaque_decl_ctx); |
60 | } |
61 | |
62 | std::vector<lldb_private::CompilerContext> |
63 | CompilerDeclContext::GetCompilerContext() const { |
64 | if (IsValid()) |
65 | return m_type_system->DeclContextGetCompilerContext(opaque_decl_ctx: m_opaque_decl_ctx); |
66 | return {}; |
67 | } |
68 | |
69 | bool lldb_private::operator==(const lldb_private::CompilerDeclContext &lhs, |
70 | const lldb_private::CompilerDeclContext &rhs) { |
71 | return lhs.GetTypeSystem() == rhs.GetTypeSystem() && |
72 | lhs.GetOpaqueDeclContext() == rhs.GetOpaqueDeclContext(); |
73 | } |
74 | |
75 | bool lldb_private::operator!=(const lldb_private::CompilerDeclContext &lhs, |
76 | const lldb_private::CompilerDeclContext &rhs) { |
77 | return lhs.GetTypeSystem() != rhs.GetTypeSystem() || |
78 | lhs.GetOpaqueDeclContext() != rhs.GetOpaqueDeclContext(); |
79 | } |
80 |