1 //===-- CompilerDeclContext.cpp ---------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "lldb/Symbol/CompilerDeclContext.h"
11 #include "lldb/Symbol/CompilerDecl.h"
12 #include "lldb/Symbol/TypeSystem.h"
13 #include <vector>
14 
15 using namespace lldb_private;
16 
17 std::vector<CompilerDecl>
18 CompilerDeclContext::FindDeclByName (ConstString name)
19 {
20     std::vector<CompilerDecl> found_decls;
21     if (IsValid())
22     {
23         std::vector<void *> found_opaque_decls = m_type_system->DeclContextFindDeclByName(m_opaque_decl_ctx, name);
24         for (void *opaque_decl : found_opaque_decls)
25             found_decls.push_back(CompilerDecl(m_type_system, opaque_decl));
26     }
27     return found_decls;
28 }
29 
30 bool
31 CompilerDeclContext::IsClang () const
32 {
33     return IsValid() && m_type_system->getKind() == TypeSystem::eKindClang;
34 }
35 
36 ConstString
37 CompilerDeclContext::GetName () const
38 {
39     if (IsValid())
40         return m_type_system->DeclContextGetName(m_opaque_decl_ctx);
41     else
42         return ConstString();
43 }
44 
45 bool
46 CompilerDeclContext::IsStructUnionOrClass () const
47 {
48     if (IsValid())
49         return m_type_system->DeclContextIsStructUnionOrClass(m_opaque_decl_ctx);
50     else
51         return false;
52 }
53 
54 bool
55 CompilerDeclContext::IsClassMethod (lldb::LanguageType *language_ptr,
56                                     bool *is_instance_method_ptr,
57                                     ConstString *language_object_name_ptr)
58 {
59     if (IsValid())
60         return m_type_system->DeclContextIsClassMethod (m_opaque_decl_ctx,
61                                                         language_ptr,
62                                                         is_instance_method_ptr,
63                                                         language_object_name_ptr);
64     else
65         return false;
66 }
67 
68 bool
69 lldb_private::operator == (const lldb_private::CompilerDeclContext &lhs, const lldb_private::CompilerDeclContext &rhs)
70 {
71     return lhs.GetTypeSystem() == rhs.GetTypeSystem() && lhs.GetOpaqueDeclContext() == rhs.GetOpaqueDeclContext();
72 }
73 
74 
75 bool
76 lldb_private::operator != (const lldb_private::CompilerDeclContext &lhs, const lldb_private::CompilerDeclContext &rhs)
77 {
78     return lhs.GetTypeSystem() != rhs.GetTypeSystem() || lhs.GetOpaqueDeclContext() != rhs.GetOpaqueDeclContext();
79 }
80