blob: 43a83bbca77bd4387e1c9df69b6d752cc46540ac [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>
Kate Stoneb9c1b512016-09-06 20:57:50 +000018CompilerDeclContext::FindDeclByName(ConstString name,
19 const bool ignore_using_decls) {
20 if (IsValid())
21 return m_type_system->DeclContextFindDeclByName(m_opaque_decl_ctx, name,
22 ignore_using_decls);
23 else
24 return std::vector<CompilerDecl>();
Paul Hermand628cbb2015-09-15 23:44:17 +000025}
26
Kate Stoneb9c1b512016-09-06 20:57:50 +000027bool CompilerDeclContext::IsClang() const {
28 return IsValid() && m_type_system->getKind() == TypeSystem::eKindClang;
Greg Clayton99558cc42015-08-24 23:46:31 +000029}
30
Kate Stoneb9c1b512016-09-06 20:57:50 +000031ConstString CompilerDeclContext::GetName() const {
32 if (IsValid())
33 return m_type_system->DeclContextGetName(m_opaque_decl_ctx);
34 else
35 return ConstString();
Greg Clayton99558cc42015-08-24 23:46:31 +000036}
37
Kate Stoneb9c1b512016-09-06 20:57:50 +000038ConstString CompilerDeclContext::GetScopeQualifiedName() const {
39 if (IsValid())
40 return m_type_system->DeclContextGetScopeQualifiedName(m_opaque_decl_ctx);
41 else
42 return ConstString();
Siva Chandra9293fc42016-01-07 23:32:34 +000043}
44
Kate Stoneb9c1b512016-09-06 20:57:50 +000045bool CompilerDeclContext::IsStructUnionOrClass() const {
46 if (IsValid())
47 return m_type_system->DeclContextIsStructUnionOrClass(m_opaque_decl_ctx);
48 else
49 return false;
Greg Clayton99558cc42015-08-24 23:46:31 +000050}
51
Kate Stoneb9c1b512016-09-06 20:57:50 +000052bool CompilerDeclContext::IsClassMethod(lldb::LanguageType *language_ptr,
53 bool *is_instance_method_ptr,
54 ConstString *language_object_name_ptr) {
55 if (IsValid())
56 return m_type_system->DeclContextIsClassMethod(
57 m_opaque_decl_ctx, language_ptr, is_instance_method_ptr,
58 language_object_name_ptr);
59 else
60 return false;
Greg Clayton99558cc42015-08-24 23:46:31 +000061}
62
Kate Stoneb9c1b512016-09-06 20:57:50 +000063bool lldb_private::operator==(const lldb_private::CompilerDeclContext &lhs,
64 const lldb_private::CompilerDeclContext &rhs) {
65 return lhs.GetTypeSystem() == rhs.GetTypeSystem() &&
66 lhs.GetOpaqueDeclContext() == rhs.GetOpaqueDeclContext();
Greg Clayton99558cc42015-08-24 23:46:31 +000067}
68
Kate Stoneb9c1b512016-09-06 20:57:50 +000069bool lldb_private::operator!=(const lldb_private::CompilerDeclContext &lhs,
70 const lldb_private::CompilerDeclContext &rhs) {
71 return lhs.GetTypeSystem() != rhs.GetTypeSystem() ||
72 lhs.GetOpaqueDeclContext() != rhs.GetOpaqueDeclContext();
Greg Clayton99558cc42015-08-24 23:46:31 +000073}