[Lldb-commits] [PATCH] D100962: [lldb/Utility] Add SourceLocationSpec class (NFC)

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Apr 21 08:41:48 PDT 2021


JDevlieghere added inline comments.


================
Comment at: lldb/include/lldb/Utility/SourceLocationSpec.h:12-19
+#include <string>
+
+#include "lldb/Utility/FileSpec.h"
+
+#include "llvm/ADT/Optional.h"
+
+#include <stddef.h>
----------------



================
Comment at: lldb/include/lldb/Utility/SourceLocationSpec.h:90
+
+  /// Convert to pointer operator.
+  ///
----------------



================
Comment at: lldb/include/lldb/Utility/SourceLocationSpec.h:126
+  /// and making both line and column value the empty string.
+  void Clear();
+
----------------
The class looks mostly immutable (which is good) so I think we can omit this.


================
Comment at: lldb/include/lldb/Utility/SourceLocationSpec.h:153
+
+  static bool Equal(const SourceLocationSpec &a, const SourceLocationSpec &b,
+                    bool full);
----------------



================
Comment at: lldb/include/lldb/Utility/SourceLocationSpec.h:160
+  /// file_spec and line number. An empty \a pattern matches everything.
+  static bool Match(const SourceLocationSpec &pattern,
+                    const SourceLocationSpec &location);
----------------
Would it make sense to merge this into Equal and replace the bool with an enum value that represents 

 - file + line must match, 
 - file + line + col must match,
 - file + line + col must match if lhs has it?


================
Comment at: lldb/include/lldb/Utility/SourceLocationSpec.h:178
+
+  bool HasColumn() const { return m_column.hasValue() && *m_column != 0; }
+
----------------
If 0 is not a valid column, we should enforce that rather than having two ways of representing it. Can we add an assert to the ctor and make it a precondition for the class? 


================
Comment at: lldb/include/lldb/Utility/SourceLocationSpec.h:184
+  FileSpec m_file_spec;
+  uint32_t m_line;
+  llvm::Optional<uint16_t> m_column;
----------------
Are there situations where the line is optional too? 


================
Comment at: lldb/unittests/Utility/SourceLocationSpecTest.cpp:1-2
+//===-- SourceLocationSpecTest.cpp
+//--------------------------------------------------===//
+//
----------------



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100962



More information about the lldb-commits mailing list