[lldb][dwarf] Compute fully qualified names on simplified template names with DWARFT...
[llvm-project.git] / lldb / source / API / SBFileSpecList.cpp
blob74a368a3cabeb689f94735c7176d7af0b46562a3
1 //===-- SBFileSpecList.cpp ------------------------------------------------===//
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 //===----------------------------------------------------------------------===//
9 #include "lldb/API/SBFileSpecList.h"
10 #include "Utils.h"
11 #include "lldb/API/SBFileSpec.h"
12 #include "lldb/API/SBStream.h"
13 #include "lldb/Host/PosixApi.h"
14 #include "lldb/Utility/FileSpec.h"
15 #include "lldb/Utility/FileSpecList.h"
16 #include "lldb/Utility/Instrumentation.h"
17 #include "lldb/Utility/Stream.h"
19 #include <climits>
21 using namespace lldb;
22 using namespace lldb_private;
24 SBFileSpecList::SBFileSpecList() : m_opaque_up(new FileSpecList()) {
25 LLDB_INSTRUMENT_VA(this);
28 SBFileSpecList::SBFileSpecList(const SBFileSpecList &rhs) {
29 LLDB_INSTRUMENT_VA(this, rhs);
31 m_opaque_up = clone(rhs.m_opaque_up);
34 SBFileSpecList::~SBFileSpecList() = default;
36 const SBFileSpecList &SBFileSpecList::operator=(const SBFileSpecList &rhs) {
37 LLDB_INSTRUMENT_VA(this, rhs);
39 if (this != &rhs)
40 m_opaque_up = clone(rhs.m_opaque_up);
41 return *this;
44 uint32_t SBFileSpecList::GetSize() const {
45 LLDB_INSTRUMENT_VA(this);
47 return m_opaque_up->GetSize();
50 void SBFileSpecList::Append(const SBFileSpec &sb_file) {
51 LLDB_INSTRUMENT_VA(this, sb_file);
53 m_opaque_up->Append(sb_file.ref());
56 bool SBFileSpecList::AppendIfUnique(const SBFileSpec &sb_file) {
57 LLDB_INSTRUMENT_VA(this, sb_file);
59 return m_opaque_up->AppendIfUnique(sb_file.ref());
62 void SBFileSpecList::Clear() {
63 LLDB_INSTRUMENT_VA(this);
65 m_opaque_up->Clear();
68 uint32_t SBFileSpecList::FindFileIndex(uint32_t idx, const SBFileSpec &sb_file,
69 bool full) {
70 LLDB_INSTRUMENT_VA(this, idx, sb_file, full);
72 return m_opaque_up->FindFileIndex(idx, sb_file.ref(), full);
75 const SBFileSpec SBFileSpecList::GetFileSpecAtIndex(uint32_t idx) const {
76 LLDB_INSTRUMENT_VA(this, idx);
78 SBFileSpec new_spec;
79 new_spec.SetFileSpec(m_opaque_up->GetFileSpecAtIndex(idx));
80 return new_spec;
83 const lldb_private::FileSpecList *SBFileSpecList::operator->() const {
84 return m_opaque_up.get();
87 const lldb_private::FileSpecList *SBFileSpecList::get() const {
88 return m_opaque_up.get();
91 const lldb_private::FileSpecList &SBFileSpecList::operator*() const {
92 return *m_opaque_up;
95 const lldb_private::FileSpecList &SBFileSpecList::ref() const {
96 return *m_opaque_up;
99 bool SBFileSpecList::GetDescription(SBStream &description) const {
100 LLDB_INSTRUMENT_VA(this, description);
102 Stream &strm = description.ref();
104 if (m_opaque_up) {
105 uint32_t num_files = m_opaque_up->GetSize();
106 strm.Printf("%d files: ", num_files);
107 for (uint32_t i = 0; i < num_files; i++) {
108 char path[PATH_MAX];
109 if (m_opaque_up->GetFileSpecAtIndex(i).GetPath(path, sizeof(path)))
110 strm.Printf("\n %s", path);
112 } else
113 strm.PutCString("No value");
115 return true;