aboutsummaryrefslogtreecommitdiffstats
path: root/include/lldb/Utility/ConstString.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/lldb/Utility/ConstString.h')
-rw-r--r--include/lldb/Utility/ConstString.h48
1 files changed, 35 insertions, 13 deletions
diff --git a/include/lldb/Utility/ConstString.h b/include/lldb/Utility/ConstString.h
index 8576c18ddcd8..9a9ee458239f 100644
--- a/include/lldb/Utility/ConstString.h
+++ b/include/lldb/Utility/ConstString.h
@@ -10,6 +10,7 @@
#define liblldb_ConstString_h_
#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/Support/FormatVariadic.h"
#include <stddef.h>
@@ -204,9 +205,7 @@ public:
/// \param[in] rhs
/// Another string object to compare this object to.
///
- /// \return
- /// \li \b true if this object is not equal to \a rhs.
- /// \li \b false if this object is equal to \a rhs.
+ /// \return \b true if this object is not equal to \a rhs, false otherwise.
bool operator!=(const char *rhs) const { return !(*this == rhs); }
bool operator<(ConstString rhs) const;
@@ -218,8 +217,7 @@ public:
///
/// If \a value_if_empty is nullptr, then nullptr will be returned.
///
- /// \return
- /// Returns \a value_if_empty if the string is empty, otherwise
+ /// \return Returns \a value_if_empty if the string is empty, otherwise
/// the C string value contained in this object.
const char *AsCString(const char *value_if_empty = nullptr) const {
return (IsEmpty() ? value_if_empty : m_string);
@@ -269,7 +267,7 @@ public:
/// in a pointer comparison since all strings are in a uniqued in a global
/// string pool.
///
- /// \param[in] rhs
+ /// \param[in] lhs
/// The Left Hand Side const ConstString object reference.
///
/// \param[in] rhs
@@ -279,9 +277,7 @@ public:
/// Case sensitivity. If true, case sensitive equality
/// will be tested, otherwise character case will be ignored
///
- /// \return
- /// \li \b true if this object is equal to \a rhs.
- /// \li \b false if this object is not equal to \a rhs.
+ /// \return \b true if this object is equal to \a rhs, \b false otherwise.
static bool Equals(ConstString lhs, ConstString rhs,
const bool case_sensitive = true);
@@ -305,10 +301,7 @@ public:
/// Case sensitivity of compare. If true, case sensitive compare
/// will be performed, otherwise character case will be ignored
///
- /// \return
- /// \li -1 if lhs < rhs
- /// \li 0 if lhs == rhs
- /// \li 1 if lhs > rhs
+ /// \return -1 if lhs < rhs, 0 if lhs == rhs, 1 if lhs > rhs
static int Compare(ConstString lhs, ConstString rhs,
const bool case_sensitive = true);
@@ -445,6 +438,14 @@ public:
static size_t StaticMemorySize();
protected:
+ template <typename T> friend struct ::llvm::DenseMapInfo;
+ /// Only used by DenseMapInfo.
+ static ConstString FromStringPoolPointer(const char *ptr) {
+ ConstString s;
+ s.m_string = ptr;
+ return s;
+ };
+
// Member variables
const char *m_string;
};
@@ -459,6 +460,27 @@ template <> struct format_provider<lldb_private::ConstString> {
static void format(const lldb_private::ConstString &CS, llvm::raw_ostream &OS,
llvm::StringRef Options);
};
+
+/// DenseMapInfo implementation.
+/// \{
+template <> struct DenseMapInfo<lldb_private::ConstString> {
+ static inline lldb_private::ConstString getEmptyKey() {
+ return lldb_private::ConstString::FromStringPoolPointer(
+ DenseMapInfo<const char *>::getEmptyKey());
+ }
+ static inline lldb_private::ConstString getTombstoneKey() {
+ return lldb_private::ConstString::FromStringPoolPointer(
+ DenseMapInfo<const char *>::getTombstoneKey());
+ }
+ static unsigned getHashValue(lldb_private::ConstString val) {
+ return DenseMapInfo<const char *>::getHashValue(val.m_string);
+ }
+ static bool isEqual(lldb_private::ConstString LHS,
+ lldb_private::ConstString RHS) {
+ return LHS == RHS;
+ }
+};
+/// \}
}
#endif // liblldb_ConstString_h_