[Lldb-commits] [PATCH] D155333: [lldb][LocateModuleCallback] Fix FileSpec compare

Jason Molenda via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Jul 14 18:16:27 PDT 2023


jasonmolenda added a comment.

Like reading third-party/unittest/googletest/include/gtest/gtest-printers.h, I thought I could add a static PrintTo method?  but

  index 6eb5b805d9d..93d98baa5be 100644
  --- a/lldb/include/lldb/Utility/FileSpec.h
  +++ b/lldb/include/lldb/Utility/FileSpec.h
  @@ -12,4 +12,5 @@
   #include <functional>
   #include <optional>
  +#include <ostream>
   #include <string>
   
  @@ -198,4 +199,8 @@ public:
     static std::optional<Style> GuessPathStyle(llvm::StringRef absolute_path);
   
  +  /// Print the file path in a FileSpec to the ostream, for gtest-printers unit
  +  /// test failure printing.
  +  static void PrintTo(const FileSpec &fspec, std::ostream *ostr);
  +
     /// Case sensitivity of path.
     ///
  diff --git a/lldb/source/Utility/FileSpec.cpp b/lldb/source/Utility/FileSpec.cpp
  index eb34ef97cea..6f09c8448df 100644
  --- a/lldb/source/Utility/FileSpec.cpp
  +++ b/lldb/source/Utility/FileSpec.cpp
  @@ -320,4 +320,8 @@ FileSpec::GuessPathStyle(llvm::StringRef absolute_path) {
   }
   
  +void FileSpec::PrintTo(const FileSpec &fspec, std::ostream *ostr) {
  +  *ostr << fspec.GetPath();
  +}
  +
   // 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

and making one of the FileSpecs not match, I still get the "24-byte object" printed for the ASSERT_EQ mismatch.  I must have misunderstood the header.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155333/new/

https://reviews.llvm.org/D155333



More information about the lldb-commits mailing list