Skip to content

Commit 1b5f72c

Browse files
committed
[lldb] Hoist SupportFile out of FileSpecList (NFC)
This hoists SupportFile out of FileSpecList. SupportFileList is still implemented there as it's very similar to FileSpecList.
1 parent 6ba2c2b commit 1b5f72c

File tree

2 files changed

+53
-28
lines changed

2 files changed

+53
-28
lines changed

lldb/include/lldb/Utility/FileSpecList.h

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,15 @@
99
#ifndef LLDB_CORE_FILESPECLIST_H
1010
#define LLDB_CORE_FILESPECLIST_H
1111

12-
#include "lldb/Utility/Checksum.h"
1312
#include "lldb/Utility/FileSpec.h"
13+
#include "lldb/Utility/SupportFile.h"
1414

1515
#include <cstddef>
1616
#include <vector>
1717

1818
namespace lldb_private {
1919
class Stream;
2020

21-
/// Wraps either a FileSpec that represents a local file or a source
22-
/// file whose contents is known (for example because it can be
23-
/// reconstructed from debug info), but that hasn't been written to a
24-
/// file yet.
25-
class SupportFile {
26-
protected:
27-
FileSpec m_file_spec;
28-
Checksum m_checksum;
29-
30-
public:
31-
SupportFile(const FileSpec &spec) : m_file_spec(spec), m_checksum() {}
32-
SupportFile(const FileSpec &spec, const Checksum &checksum)
33-
: m_file_spec(spec), m_checksum(checksum) {}
34-
SupportFile(const SupportFile &other) = delete;
35-
SupportFile(SupportFile &&other) = default;
36-
virtual ~SupportFile() = default;
37-
bool operator==(const SupportFile &other) {
38-
return m_file_spec == other.m_file_spec && m_checksum == other.m_checksum;
39-
}
40-
/// Return the file name only. Useful for resolving breakpoints by file name.
41-
const FileSpec &GetSpecOnly() const { return m_file_spec; };
42-
/// Return the checksum or all zeros if there is none.
43-
const Checksum &GetChecksum() const { return m_checksum; };
44-
/// Materialize the file to disk and return the path to that temporary file.
45-
virtual const FileSpec &Materialize() { return m_file_spec; }
46-
};
47-
4821
/// A list of support files for a CompileUnit.
4922
class SupportFileList {
5023
public:
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//===-- SupportFile.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_UTILITY_SUPPORTFILE_H
10+
#define LLDB_UTILITY_SUPPORTFILE_H
11+
12+
#include "lldb/Utility/Checksum.h"
13+
#include "lldb/Utility/FileSpec.h"
14+
15+
namespace lldb_private {
16+
17+
/// Wraps either a FileSpec that represents a local file or a source
18+
/// file whose contents is known (for example because it can be
19+
/// reconstructed from debug info), but that hasn't been written to a
20+
/// file yet. This also stores an optional checksum of the on-disk content.
21+
class SupportFile {
22+
public:
23+
SupportFile(const FileSpec &spec) : m_file_spec(spec), m_checksum() {}
24+
SupportFile(const FileSpec &spec, const Checksum &checksum)
25+
: m_file_spec(spec), m_checksum(checksum) {}
26+
27+
SupportFile(const SupportFile &other) = delete;
28+
SupportFile(SupportFile &&other) = default;
29+
30+
virtual ~SupportFile() = default;
31+
32+
bool operator==(const SupportFile &other) {
33+
return m_file_spec == other.m_file_spec && m_checksum == other.m_checksum;
34+
}
35+
36+
/// Return the file name only. Useful for resolving breakpoints by file name.
37+
const FileSpec &GetSpecOnly() const { return m_file_spec; };
38+
39+
/// Return the checksum or all zeros if there is none.
40+
const Checksum &GetChecksum() const { return m_checksum; };
41+
42+
/// Materialize the file to disk and return the path to that temporary file.
43+
virtual const FileSpec &Materialize() { return m_file_spec; }
44+
45+
protected:
46+
FileSpec m_file_spec;
47+
Checksum m_checksum;
48+
};
49+
50+
} // namespace lldb_private
51+
52+
#endif // LLDB_UTILITY_SUPPORTFILE_H

0 commit comments

Comments
 (0)