-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb] Add Checksum to FileSpec #71457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
#include <optional> | ||
#include <string> | ||
|
||
#include "lldb/Utility/Checksum.h" | ||
#include "lldb/Utility/ConstString.h" | ||
|
||
#include "llvm/ADT/StringRef.h" | ||
|
@@ -71,8 +72,12 @@ class FileSpec { | |
/// \param[in] style | ||
/// The style of the path | ||
/// | ||
/// \param[in] checksum | ||
/// The MD5 checksum of the path. | ||
/// | ||
/// \see FileSpec::SetFile (const char *path) | ||
explicit FileSpec(llvm::StringRef path, Style style = Style::native); | ||
explicit FileSpec(llvm::StringRef path, Style style = Style::native, | ||
const Checksum &checksum = {}); | ||
|
||
explicit FileSpec(llvm::StringRef path, const llvm::Triple &triple); | ||
|
||
|
@@ -362,7 +367,11 @@ class FileSpec { | |
/// | ||
/// \param[in] style | ||
/// The style for the given path. | ||
void SetFile(llvm::StringRef path, Style style); | ||
/// | ||
/// \param[in] checksum | ||
/// The checksum for the given path. | ||
void SetFile(llvm::StringRef path, Style style, | ||
const Checksum &checksum = {}); | ||
|
||
/// Change the file specified with a new path. | ||
/// | ||
|
@@ -420,13 +429,17 @@ class FileSpec { | |
/// The lifetime of the StringRefs is tied to the lifetime of the FileSpec. | ||
std::vector<llvm::StringRef> GetComponents() const; | ||
|
||
/// Return the checksum for this FileSpec or all zeros if there is none. | ||
const Checksum &GetChecksum() const { return m_checksum; }; | ||
|
||
protected: | ||
// Convenience method for setting the file without changing the style. | ||
void SetFile(llvm::StringRef path); | ||
|
||
/// Called anytime m_directory or m_filename is changed to clear any cached | ||
/// state in this object. | ||
void PathWasModified() { | ||
m_checksum = Checksum(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be nice to recompute the checksum if the path was changed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that the FileSpec is a system independent path description (i.e. the file doesn't need to exist on the host) there's no way to recompute it automatically, although the user can specify a new checksum if the path changes. |
||
m_is_resolved = false; | ||
m_absolute = Absolute::Calculate; | ||
} | ||
|
@@ -443,6 +456,9 @@ class FileSpec { | |
/// The unique'd filename path. | ||
ConstString m_filename; | ||
|
||
/// The optional MD5 checksum of the file. | ||
Checksum m_checksum; | ||
|
||
/// True if this path has been resolved. | ||
mutable bool m_is_resolved = false; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update the doxygen