14#include "llvm/ADT/StringRef.h"
15#include "llvm/ADT/iterator.h"
16#include "llvm/Support/FormatProviders.h"
31 StringPool::GetGlobal().GetConstCStringWithLength(cstr, cstr_len)) {}
44 if (lhs_string_ref.data() && rhs_string_ref.data())
45 return lhs_string_ref < rhs_string_ref;
48 return lhs_string_ref.data() ==
nullptr;
64 const bool case_sensitive) {
77 return lhs_string_ref.equals_insensitive(rhs_string_ref);
81 const bool case_sensitive) {
85 if (lhs_cstr == rhs_cstr)
87 if (lhs_cstr && rhs_cstr) {
92 return lhs_string_ref.compare(rhs_string_ref);
94 return lhs_string_ref.compare_insensitive(rhs_string_ref);
106 const char *cstr =
AsCString(fail_value);
116 const char *parens = cstr ?
"\"" :
"";
117 s->
Printf(
"%*p: ConstString, string = %s%s%s, length = %" PRIu64,
118 static_cast<int>(
sizeof(
void *) * 2),
119 static_cast<const void *
>(
this), parens, cstr, parens,
120 static_cast<uint64_t
>(cstr_len));
140 return (
bool)counterpart;
157void llvm::format_provider<ConstString>::format(
const ConstString &CS,
158 llvm::raw_ostream &
OS,
A uniqued constant string class.
bool GetMangledCounterpart(ConstString &counterpart) const
Retrieve the mangled or demangled counterpart for a mangled or demangled ConstString.
static MemoryStats GetMemoryStats()
void SetCStringWithLength(const char *cstr, size_t cstr_len)
Set the C string value with length.
void SetCString(const char *cstr)
Set the C string value.
static int Compare(ConstString lhs, ConstString rhs, const bool case_sensitive=true)
Compare two string objects.
ConstString()=default
Default constructor.
void Dump(Stream *s, const char *value_if_empty=nullptr) const
Dump the object description to a stream.
static bool Equals(ConstString lhs, ConstString rhs, const bool case_sensitive=true)
Equal to operator.
void DumpDebug(Stream *s) const
Dump the object debug description to a stream.
void SetTrimmedCStringWithLength(const char *cstr, size_t fixed_cstr_len)
Set the C string value with the minimum length between fixed_cstr_len and the actual length of the C ...
size_t GetLength() const
Get the length in bytes of string value.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
void SetString(llvm::StringRef s)
bool operator<(ConstString rhs) const
const char * GetCString() const
Get the string value as a C string.
void SetStringWithMangledCounterpart(llvm::StringRef demangled, ConstString mangled)
Set the C string value and its mangled counterpart.
const char * AsCString(const char *value_if_empty) const
Get the string value as a C string.
A command line option parsing protocol class.
A stream class that can stream formatted output to a file.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
A thread-safe pool of interned, null-terminated strings.
const char * GetConstCString(const char *cstr)
const char * Intern(llvm::StringRef str)
Returns the pooled copy of str, or nullptr if str has no data.
const char * GetMangledCounterpart(llvm::StringRef str)
ConstString::MemoryStats GetMemoryStats() const
const char * GetConstCStringWithLength(const char *cstr, size_t cstr_len)
static StringPool & GetGlobal()
The pool backing ConstString. It is never destroyed.
static size_t GetConstCStringLength(const char *ccstr)
Length of a string returned by any pool.
const char * GetConstTrimmedCStringWithLength(const char *cstr, size_t cstr_len)
const char * GetConstCStringAndSetMangledCounterPart(llvm::StringRef demangled, llvm::StringRef mangled)
Interns demangled and links it with the already interned mangled.
A class that represents a running process on the host machine.
Stream & operator<<(Stream &s, const Mangled &obj)