blob: e44cee67284c0c196f3eb8956f63a9a7a5b2afd8 [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{
Paul Hermand628cbb2015-09-15 23:44:17 +000020 if (IsValid())
Greg Claytondfc09622015-12-08 18:39:50 +000021 return m_type_system->DeclContextFindDeclByName(m_opaque_decl_ctx, name);
22 else
23 return std::vector<CompilerDecl>();
Paul Hermand628cbb2015-09-15 23:44:17 +000024}
25
Greg Clayton99558cc42015-08-24 23:46:31 +000026bool
27CompilerDeclContext::IsClang () const
28{
Greg Claytonf73034f2015-09-08 18:15:05 +000029 return IsValid() && m_type_system->getKind() == TypeSystem::eKindClang;
Greg Clayton99558cc42015-08-24 23:46:31 +000030}
31
32ConstString
33CompilerDeclContext::GetName () const
34{
35 if (IsValid())
36 return m_type_system->DeclContextGetName(m_opaque_decl_ctx);
37 else
38 return ConstString();
39}
40
41bool
42CompilerDeclContext::IsStructUnionOrClass () const
43{
44 if (IsValid())
45 return m_type_system->DeclContextIsStructUnionOrClass(m_opaque_decl_ctx);
46 else
47 return false;
48}
49
50bool
51CompilerDeclContext::IsClassMethod (lldb::LanguageType *language_ptr,
52 bool *is_instance_method_ptr,
53 ConstString *language_object_name_ptr)
54{
55 if (IsValid())
56 return m_type_system->DeclContextIsClassMethod (m_opaque_decl_ctx,
57 language_ptr,
58 is_instance_method_ptr,
59 language_object_name_ptr);
60 else
61 return false;
62}
63
64bool
65lldb_private::operator == (const lldb_private::CompilerDeclContext &lhs, const lldb_private::CompilerDeclContext &rhs)
66{
67 return lhs.GetTypeSystem() == rhs.GetTypeSystem() && lhs.GetOpaqueDeclContext() == rhs.GetOpaqueDeclContext();
68}
69
70
71bool
72lldb_private::operator != (const lldb_private::CompilerDeclContext &lhs, const lldb_private::CompilerDeclContext &rhs)
73{
74 return lhs.GetTypeSystem() != rhs.GetTypeSystem() || lhs.GetOpaqueDeclContext() != rhs.GetOpaqueDeclContext();
75}