blob: a28ea8d86082ac75bbca57157173748463df4d3b [file] [log] [blame]
Greg Clayton99558cc42015-08-24 23:46:31 +00001//===-- 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"
Paul Hermand628cbb2015-09-15 23:44:17 +000011#include "lldb/Symbol/CompilerDecl.h"
Greg Clayton99558cc42015-08-24 23:46:31 +000012#include "lldb/Symbol/TypeSystem.h"
Paul Hermand628cbb2015-09-15 23:44:17 +000013#include <vector>
Greg Clayton99558cc42015-08-24 23:46:31 +000014
15using namespace lldb_private;
16
Paul Hermand628cbb2015-09-15 23:44:17 +000017std::vector<CompilerDecl>
18CompilerDeclContext::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
Greg Clayton99558cc42015-08-24 23:46:31 +000030bool
31CompilerDeclContext::IsClang () const
32{
Greg Claytonf73034f2015-09-08 18:15:05 +000033 return IsValid() && m_type_system->getKind() == TypeSystem::eKindClang;
Greg Clayton99558cc42015-08-24 23:46:31 +000034}
35
36ConstString
37CompilerDeclContext::GetName () const
38{
39 if (IsValid())
40 return m_type_system->DeclContextGetName(m_opaque_decl_ctx);
41 else
42 return ConstString();
43}
44
45bool
46CompilerDeclContext::IsStructUnionOrClass () const
47{
48 if (IsValid())
49 return m_type_system->DeclContextIsStructUnionOrClass(m_opaque_decl_ctx);
50 else
51 return false;
52}
53
54bool
55CompilerDeclContext::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
68bool
69lldb_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
75bool
76lldb_private::operator != (const lldb_private::CompilerDeclContext &lhs, const lldb_private::CompilerDeclContext &rhs)
77{
78 return lhs.GetTypeSystem() != rhs.GetTypeSystem() || lhs.GetOpaqueDeclContext() != rhs.GetOpaqueDeclContext();
79}