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_
15 #include "lldb/Utility/ConstString.h"
16 #include "DWARFDefines.h"
18 //----------------------------------------------------------------------
21 // A class that represents a declaration context all the way down to a
22 // DIE. This is useful when trying to find a DIE in one DWARF to a DIE
23 // in another DWARF file.
24 //----------------------------------------------------------------------
26 class DWARFDeclContext {
29 Entry() : tag(0), name(NULL) {}
30 Entry(dw_tag_t t, const char *n) : tag(t), name(n) {}
32 bool NameMatches(const Entry &rhs) const {
35 else if (name && rhs.name)
36 return strcmp(name, rhs.name) == 0;
41 explicit operator bool() const { return tag != 0; }
47 DWARFDeclContext() : m_entries(), m_language(lldb::eLanguageTypeUnknown) {}
49 void AppendDeclContext(dw_tag_t tag, const char *name) {
50 m_entries.push_back(Entry(tag, name));
53 bool operator==(const DWARFDeclContext &rhs) const;
55 uint32_t GetSize() const { return m_entries.size(); }
57 Entry &operator[](uint32_t idx) {
58 // "idx" must be valid
59 return m_entries[idx];
62 const Entry &operator[](uint32_t idx) const {
63 // "idx" must be valid
64 return m_entries[idx];
67 const char *GetQualifiedName() const;
69 // Same as GetQaulifiedName, but the life time of the returned string will
70 // be that of the LLDB session.
71 lldb_private::ConstString GetQualifiedNameAsConstString() const {
72 return lldb_private::ConstString(GetQualifiedName());
77 m_qualified_name.clear();
80 lldb::LanguageType GetLanguage() const { return m_language; }
82 void SetLanguage(lldb::LanguageType language) { m_language = language; }
85 typedef std::vector<Entry> collection;
87 mutable std::string m_qualified_name;
88 lldb::LanguageType m_language;
91 #endif // SymbolFileDWARF_DWARFDeclContext_h_