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