1 //===-- DWARFDeclContext.h --------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef SymbolFileDWARF_DWARFDeclContext_h_
11 #define SymbolFileDWARF_DWARFDeclContext_h_
17 // Other libraries and framework includes
18 #include "lldb/Utility/ConstString.h"
20 #include "DWARFDefines.h"
22 //----------------------------------------------------------------------
25 // A class that represents a declaration context all the way down to a
26 // DIE. This is useful when trying to find a DIE in one DWARF to a DIE
27 // in another DWARF file.
28 //----------------------------------------------------------------------
30 class DWARFDeclContext {
33 Entry() : tag(0), name(NULL) {}
34 Entry(dw_tag_t t, const char *n) : tag(t), name(n) {}
36 bool NameMatches(const Entry &rhs) const {
39 else if (name && rhs.name)
40 return strcmp(name, rhs.name) == 0;
45 explicit operator bool() const { return tag != 0; }
51 DWARFDeclContext() : m_entries(), m_language(lldb::eLanguageTypeUnknown) {}
53 void AppendDeclContext(dw_tag_t tag, const char *name) {
54 m_entries.push_back(Entry(tag, name));
57 bool operator==(const DWARFDeclContext &rhs) const;
59 uint32_t GetSize() const { return m_entries.size(); }
61 Entry &operator[](uint32_t idx) {
62 // "idx" must be valid
63 return m_entries[idx];
66 const Entry &operator[](uint32_t idx) const {
67 // "idx" must be valid
68 return m_entries[idx];
71 const char *GetQualifiedName() const;
73 // Same as GetQaulifiedName, but the life time of the returned string will
74 // be that of the LLDB session.
75 lldb_private::ConstString GetQualifiedNameAsConstString() const {
76 return lldb_private::ConstString(GetQualifiedName());
81 m_qualified_name.clear();
84 lldb::LanguageType GetLanguage() const { return m_language; }
86 void SetLanguage(lldb::LanguageType language) { m_language = language; }
89 typedef std::vector<Entry> collection;
91 mutable std::string m_qualified_name;
92 lldb::LanguageType m_language;
95 #endif // SymbolFileDWARF_DWARFDeclContext_h_