LLDB  mainline
DWARFDeclContext.h
Go to the documentation of this file.
1 //===-- DWARFDeclContext.h --------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDECLCONTEXT_H
10 #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDECLCONTEXT_H
11 
12 #include <string>
13 #include <vector>
15 #include "DWARFDefines.h"
16 
17 // DWARFDeclContext
18 //
19 // A class that represents a declaration context all the way down to a
20 // DIE. This is useful when trying to find a DIE in one DWARF to a DIE
21 // in another DWARF file.
22 
24 public:
25  struct Entry {
26  Entry() : tag(llvm::dwarf::DW_TAG_null), name(nullptr) {}
27  Entry(dw_tag_t t, const char *n) : tag(t), name(n) {}
28 
29  bool NameMatches(const Entry &rhs) const {
30  if (name == rhs.name)
31  return true;
32  else if (name && rhs.name)
33  return strcmp(name, rhs.name) == 0;
34  return false;
35  }
36 
37  // Test operator
38  explicit operator bool() const { return tag != 0; }
39 
41  const char *name;
42  };
43 
45 
46  void AppendDeclContext(dw_tag_t tag, const char *name) {
47  m_entries.push_back(Entry(tag, name));
48  }
49 
50  bool operator==(const DWARFDeclContext &rhs) const;
51  bool operator!=(const DWARFDeclContext &rhs) const { return !(*this == rhs); }
52 
53  uint32_t GetSize() const { return m_entries.size(); }
54 
56  // "idx" must be valid
57  return m_entries[idx];
58  }
59 
60  const Entry &operator[](uint32_t idx) const {
61  // "idx" must be valid
62  return m_entries[idx];
63  }
64 
65  const char *GetQualifiedName() const;
66 
67  // Same as GetQualifiedName, but the life time of the returned string will
68  // be that of the LLDB session.
71  }
72 
73  void Clear() {
74  m_entries.clear();
75  m_qualified_name.clear();
76  }
77 
79 
80  void SetLanguage(lldb::LanguageType language) { m_language = language; }
81 
82 protected:
83  typedef std::vector<Entry> collection;
87 };
88 
89 #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDECLCONTEXT_H
DWARFDeclContext::m_entries
collection m_entries
Definition: DWARFDeclContext.h:84
DWARFDeclContext::operator[]
Entry & operator[](uint32_t idx)
Definition: DWARFDeclContext.h:55
DWARFDeclContext::Entry
Definition: DWARFDeclContext.h:25
llvm
Definition: Debugger.h:49
DWARFDeclContext::Entry::tag
dw_tag_t tag
Definition: DWARFDeclContext.h:40
DWARFDeclContext::operator==
bool operator==(const DWARFDeclContext &rhs) const
Definition: DWARFDeclContext.cpp:54
DWARFDeclContext::collection
std::vector< Entry > collection
Definition: DWARFDeclContext.h:83
dw_tag_t
llvm::dwarf::Tag dw_tag_t
Definition: dwarf.h:25
lldb::LanguageType
LanguageType
Programming language type.
Definition: lldb-enumerations.h:436
DWARFDeclContext::m_language
lldb::LanguageType m_language
Definition: DWARFDeclContext.h:86
DWARFDefines.h
DWARFDeclContext::Entry::NameMatches
bool NameMatches(const Entry &rhs) const
Definition: DWARFDeclContext.h:29
DWARFDeclContext::m_qualified_name
std::string m_qualified_name
Definition: DWARFDeclContext.h:85
DWARFDeclContext::GetQualifiedNameAsConstString
lldb_private::ConstString GetQualifiedNameAsConstString() const
Definition: DWARFDeclContext.h:69
dwarf
Definition: ABISysV_arc.cpp:61
DWARFDeclContext::GetQualifiedName
const char * GetQualifiedName() const
Definition: DWARFDeclContext.cpp:11
DWARFDeclContext::GetSize
uint32_t GetSize() const
Definition: DWARFDeclContext.h:53
DWARFDeclContext::AppendDeclContext
void AppendDeclContext(dw_tag_t tag, const char *name)
Definition: DWARFDeclContext.h:46
lldb_private::ConstString
Definition: ConstString.h:40
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:38
DWARFDeclContext::DWARFDeclContext
DWARFDeclContext()
Definition: DWARFDeclContext.h:44
DWARFDeclContext::GetLanguage
lldb::LanguageType GetLanguage() const
Definition: DWARFDeclContext.h:78
lldb::eLanguageTypeUnknown
@ eLanguageTypeUnknown
Unknown or invalid language value.
Definition: lldb-enumerations.h:437
uint32_t
DWARFDeclContext::Clear
void Clear()
Definition: DWARFDeclContext.h:73
DWARFDeclContext::operator[]
const Entry & operator[](uint32_t idx) const
Definition: DWARFDeclContext.h:60
DWARFDeclContext
Definition: DWARFDeclContext.h:23
DWARFDeclContext::Entry::name
const char * name
Definition: DWARFDeclContext.h:41
DWARFDeclContext::SetLanguage
void SetLanguage(lldb::LanguageType language)
Definition: DWARFDeclContext.h:80
DWARFDeclContext::Entry::Entry
Entry(dw_tag_t t, const char *n)
Definition: DWARFDeclContext.h:27
ConstString.h
Entry
FormatEntity::Entry Entry
Definition: FormatEntity.cpp:82
DWARFDeclContext::Entry::Entry
Entry()
Definition: DWARFDeclContext.h:26
DWARFDeclContext::operator!=
bool operator!=(const DWARFDeclContext &rhs) const
Definition: DWARFDeclContext.h:51
lldb
Definition: SBAddress.h:15