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