diff options
Diffstat (limited to 'lldb/source/Utility/FileSpec.cpp')
| -rw-r--r-- | lldb/source/Utility/FileSpec.cpp | 98 |
1 files changed, 45 insertions, 53 deletions
diff --git a/lldb/source/Utility/FileSpec.cpp b/lldb/source/Utility/FileSpec.cpp index 0a10fcad99c..2168948fa81 100644 --- a/lldb/source/Utility/FileSpec.cpp +++ b/lldb/source/Utility/FileSpec.cpp @@ -166,8 +166,7 @@ void FileSpec::Resolve(llvm::SmallVectorImpl<char> &path) { FileSpec::FileSpec() : m_syntax(GetNativeSyntax()) {} //------------------------------------------------------------------ -// Default constructor that can take an optional full path to a -// file on disk. +// Default constructor that can take an optional full path to a file on disk. //------------------------------------------------------------------ FileSpec::FileSpec(llvm::StringRef path, bool resolve_path, PathSyntax syntax) : m_syntax(syntax) { @@ -307,15 +306,15 @@ const FileSpec &FileSpec::operator=(const FileSpec &rhs) { } //------------------------------------------------------------------ -// Update the contents of this object with a new path. The path will -// be split up into a directory and filename and stored as uniqued -// string values for quick comparison and efficient memory usage. +// Update the contents of this object with a new path. The path will be split +// up into a directory and filename and stored as uniqued string values for +// quick comparison and efficient memory usage. //------------------------------------------------------------------ void FileSpec::SetFile(llvm::StringRef pathname, bool resolve, PathSyntax syntax) { // CLEANUP: Use StringRef for string handling. This function is kind of a - // mess and the unclear semantics of RootDirStart and ParentPathEnd make - // it very difficult to understand this function. There's no reason this + // mess and the unclear semantics of RootDirStart and ParentPathEnd make it + // very difficult to understand this function. There's no reason this // function should be particularly complicated or difficult to understand. m_filename.Clear(); m_directory.Clear(); @@ -369,8 +368,8 @@ void FileSpec::SetFile(llvm::StringRef path, bool resolve, } //---------------------------------------------------------------------- -// Convert to pointer operator. This allows code to check any FileSpec -// objects to see if they contain anything valid using code such as: +// Convert to pointer operator. This allows code to check any FileSpec objects +// to see if they contain anything valid using code such as: // // if (file_spec) // {} @@ -378,8 +377,8 @@ void FileSpec::SetFile(llvm::StringRef path, bool resolve, FileSpec::operator bool() const { return m_filename || m_directory; } //---------------------------------------------------------------------- -// Logical NOT operator. This allows code to check any FileSpec -// objects to see if they are invalid using code such as: +// Logical NOT operator. This allows code to check any FileSpec objects to see +// if they are invalid using code such as: // // if (!file_spec) // {} @@ -406,12 +405,10 @@ bool FileSpec::operator==(const FileSpec &rhs) const { return true; // TODO: determine if we want to keep this code in here. - // The code below was added to handle a case where we were - // trying to set a file and line breakpoint and one path - // was resolved, and the other not and the directory was - // in a mount point that resolved to a more complete path: - // "/tmp/a.c" == "/private/tmp/a.c". I might end up pulling - // this out... + // The code below was added to handle a case where we were trying to set a + // file and line breakpoint and one path was resolved, and the other not and + // the directory was in a mount point that resolved to a more complete path: + // "/tmp/a.c" == "/private/tmp/a.c". I might end up pulling this out... if (IsResolved() && rhs.IsResolved()) { // Both paths are resolved, no need to look further... return false; @@ -423,8 +420,8 @@ bool FileSpec::operator==(const FileSpec &rhs) const { if (!IsResolved()) { if (resolved_lhs.ResolvePath()) { // This path wasn't resolved but now it is. Check if the resolved - // directory is the same as our unresolved directory, and if so, - // we can mark this object as resolved to avoid more future resolves + // directory is the same as our unresolved directory, and if so, we can + // mark this object as resolved to avoid more future resolves m_is_resolved = (m_directory == resolved_lhs.m_directory); } else return false; @@ -434,16 +431,16 @@ bool FileSpec::operator==(const FileSpec &rhs) const { if (!rhs.IsResolved()) { if (resolved_rhs.ResolvePath()) { // rhs's path wasn't resolved but now it is. Check if the resolved - // directory is the same as rhs's unresolved directory, and if so, - // we can mark this object as resolved to avoid more future resolves + // directory is the same as rhs's unresolved directory, and if so, we can + // mark this object as resolved to avoid more future resolves rhs.m_is_resolved = (rhs.m_directory == resolved_rhs.m_directory); } else return false; } - // If we reach this point in the code we were able to resolve both paths - // and since we only resolve the paths if the basenames are equal, then - // we can just check if both directories are equal... + // If we reach this point in the code we were able to resolve both paths and + // since we only resolve the paths if the basenames are equal, then we can + // just check if both directories are equal... return DirectoryEquals(rhs); } @@ -468,8 +465,8 @@ Stream &lldb_private::operator<<(Stream &s, const FileSpec &f) { } //------------------------------------------------------------------ -// Clear this object by releasing both the directory and filename -// string values and making them both the empty string. +// Clear this object by releasing both the directory and filename string values +// and making them both the empty string. //------------------------------------------------------------------ void FileSpec::Clear() { m_directory.Clear(); @@ -477,15 +474,14 @@ void FileSpec::Clear() { } //------------------------------------------------------------------ -// Compare two FileSpec objects. If "full" is true, then both -// the directory and the filename must match. If "full" is false, -// then the directory names for "a" and "b" are only compared if -// they are both non-empty. This allows a FileSpec object to only -// contain a filename and it can match FileSpec objects that have -// matching filenames with different paths. +// Compare two FileSpec objects. If "full" is true, then both the directory and +// the filename must match. If "full" is false, then the directory names for +// "a" and "b" are only compared if they are both non-empty. This allows a +// FileSpec object to only contain a filename and it can match FileSpec objects +// that have matching filenames with different paths. // -// Return -1 if the "a" is less than "b", 0 if "a" is equal to "b" -// and "1" if "a" is greater than "b". +// Return -1 if the "a" is less than "b", 0 if "a" is equal to "b" and "1" if +// "a" is greater than "b". //------------------------------------------------------------------ int FileSpec::Compare(const FileSpec &a, const FileSpec &b, bool full) { int result = 0; @@ -495,10 +491,10 @@ int FileSpec::Compare(const FileSpec &a, const FileSpec &b, bool full) { // If full is true, then we must compare both the directory and filename. - // If full is false, then if either directory is empty, then we match on - // the basename only, and if both directories have valid values, we still - // do a full compare. This allows for matching when we just have a filename - // in one of the FileSpec objects. + // If full is false, then if either directory is empty, then we match on the + // basename only, and if both directories have valid values, we still do a + // full compare. This allows for matching when we just have a filename in one + // of the FileSpec objects. if (full || (a.m_directory && b.m_directory)) { result = ConstString::Compare(a.m_directory, b.m_directory, case_sensitive); @@ -527,9 +523,9 @@ bool FileSpec::Equal(const FileSpec &a, const FileSpec &b, bool full) { } //------------------------------------------------------------------ -// Dump the object to the supplied stream. If the object contains -// a valid directory name, it will be displayed followed by a -// directory delimiter, and the filename. +// Dump the object to the supplied stream. If the object contains a valid +// directory name, it will be displayed followed by a directory delimiter, and +// the filename. //------------------------------------------------------------------ void FileSpec::Dump(Stream *s) const { if (s) { @@ -572,8 +568,7 @@ bool FileSpec::ResolveExecutableLocation() { return true; else { // If FindProgramByName found the file, it returns the directory + - // filename in its return results. - // We need to separate them. + // filename in its return results. We need to separate them. FileSpec tmp_file(dir_ref.data(), false); if (tmp_file.Exists()) { m_directory = tmp_file.m_directory; @@ -635,9 +630,8 @@ ConstString &FileSpec::GetFilename() { return m_filename; } const ConstString &FileSpec::GetFilename() const { return m_filename; } //------------------------------------------------------------------ -// Extract the directory and path into a fixed buffer. This is -// needed as the directory and path are stored in separate string -// values. +// Extract the directory and path into a fixed buffer. This is needed as the +// directory and path are stored in separate string values. //------------------------------------------------------------------ size_t FileSpec::GetPath(char *path, size_t path_max_len, bool denormalize) const { @@ -698,9 +692,8 @@ ConstString FileSpec::GetFileNameStrippingExtension() const { } //------------------------------------------------------------------ -// Return the size in bytes that this object takes in memory. This -// returns the size in bytes of this object, not any shared string -// values it may refer to. +// Return the size in bytes that this object takes in memory. This returns the +// size in bytes of this object, not any shared string values it may refer to. //------------------------------------------------------------------ size_t FileSpec::MemorySize() const { return m_filename.MemorySize() + m_directory.MemorySize(); @@ -961,10 +954,9 @@ void llvm::format_provider<FileSpec>::format(const FileSpec &F, // Style is either D or empty, either way we need to print the directory. if (!dir.empty()) { - // Directory is stored in normalized form, which might be different - // than preferred form. In order to handle this, we need to cut off - // the filename, then denormalize, then write the entire denorm'ed - // directory. + // Directory is stored in normalized form, which might be different than + // preferred form. In order to handle this, we need to cut off the + // filename, then denormalize, then write the entire denorm'ed directory. llvm::SmallString<64> denormalized_dir = dir; Denormalize(denormalized_dir, F.GetPathSyntax()); Stream << denormalized_dir; |

