mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-09 01:29:52 +00:00
Convert UniqueCStringMap to use StringRef.
llvm-svn: 283494
This commit is contained in:
parent
60fb35b20a
commit
4fa098a5c0
@ -364,7 +364,7 @@ public:
|
||||
/// @param[in] cstr
|
||||
/// The string to be output to the stream.
|
||||
//------------------------------------------------------------------
|
||||
size_t PutCString(const char *cstr);
|
||||
size_t PutCString(llvm::StringRef cstr);
|
||||
|
||||
//------------------------------------------------------------------
|
||||
/// Output and End of Line character to the stream.
|
||||
|
@ -33,15 +33,15 @@ namespace lldb_private {
|
||||
template <typename T> class UniqueCStringMap {
|
||||
public:
|
||||
struct Entry {
|
||||
Entry() : cstring(nullptr), value() {}
|
||||
Entry() {}
|
||||
|
||||
Entry(const char *cstr) : cstring(cstr), value() {}
|
||||
Entry(llvm::StringRef cstr) : cstring(cstr), value() {}
|
||||
|
||||
Entry(const char *cstr, const T &v) : cstring(cstr), value(v) {}
|
||||
Entry(llvm::StringRef cstr, const T &v) : cstring(cstr), value(v) {}
|
||||
|
||||
bool operator<(const Entry &rhs) const { return cstring < rhs.cstring; }
|
||||
|
||||
const char *cstring;
|
||||
llvm::StringRef cstring;
|
||||
T value;
|
||||
};
|
||||
|
||||
@ -50,7 +50,7 @@ public:
|
||||
// this map, then later call UniqueCStringMap<T>::Sort() before doing
|
||||
// any searches by name.
|
||||
//------------------------------------------------------------------
|
||||
void Append(const char *unique_cstr, const T &value) {
|
||||
void Append(llvm::StringRef unique_cstr, const T &value) {
|
||||
m_map.push_back(typename UniqueCStringMap<T>::Entry(unique_cstr, value));
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ public:
|
||||
// Call this function to always keep the map sorted when putting
|
||||
// entries into the map.
|
||||
//------------------------------------------------------------------
|
||||
void Insert(const char *unique_cstr, const T &value) {
|
||||
void Insert(llvm::StringRef unique_cstr, const T &value) {
|
||||
typename UniqueCStringMap<T>::Entry e(unique_cstr, value);
|
||||
m_map.insert(std::upper_bound(m_map.begin(), m_map.end(), e), e);
|
||||
}
|
||||
@ -85,7 +85,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *GetCStringAtIndexUnchecked(uint32_t idx) const {
|
||||
llvm::StringRef GetCStringAtIndexUnchecked(uint32_t idx) const {
|
||||
return m_map[idx].cstring;
|
||||
}
|
||||
|
||||
@ -99,8 +99,8 @@ public:
|
||||
return m_map[idx].value;
|
||||
}
|
||||
|
||||
const char *GetCStringAtIndex(uint32_t idx) const {
|
||||
return ((idx < m_map.size()) ? m_map[idx].cstring : nullptr);
|
||||
llvm::StringRef GetCStringAtIndex(uint32_t idx) const {
|
||||
return ((idx < m_map.size()) ? m_map[idx].cstring : llvm::StringRef());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
@ -111,7 +111,7 @@ public:
|
||||
// T values and only if there is a sensible failure value that can
|
||||
// be returned and that won't match any existing values.
|
||||
//------------------------------------------------------------------
|
||||
T Find(const char *unique_cstr, T fail_value) const {
|
||||
T Find(llvm::StringRef unique_cstr, T fail_value) const {
|
||||
Entry search_entry(unique_cstr);
|
||||
const_iterator end = m_map.end();
|
||||
const_iterator pos = std::lower_bound(m_map.begin(), end, search_entry);
|
||||
@ -129,12 +129,12 @@ public:
|
||||
// The caller is responsible for ensuring that the collection does
|
||||
// not change during while using the returned pointer.
|
||||
//------------------------------------------------------------------
|
||||
const Entry *FindFirstValueForName(const char *unique_cstr) const {
|
||||
const Entry *FindFirstValueForName(llvm::StringRef unique_cstr) const {
|
||||
Entry search_entry(unique_cstr);
|
||||
const_iterator end = m_map.end();
|
||||
const_iterator pos = std::lower_bound(m_map.begin(), end, search_entry);
|
||||
if (pos != end) {
|
||||
const char *pos_cstr = pos->cstring;
|
||||
llvm::StringRef pos_cstr = pos->cstring;
|
||||
if (pos_cstr == unique_cstr)
|
||||
return &(*pos);
|
||||
}
|
||||
@ -162,7 +162,7 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
size_t GetValues(const char *unique_cstr, std::vector<T> &values) const {
|
||||
size_t GetValues(llvm::StringRef unique_cstr, std::vector<T> &values) const {
|
||||
const size_t start_size = values.size();
|
||||
|
||||
Entry search_entry(unique_cstr);
|
||||
@ -238,7 +238,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
size_t Erase(const char *unique_cstr) {
|
||||
size_t Erase(llvm::StringRef unique_cstr) {
|
||||
size_t num_removed = 0;
|
||||
Entry search_entry(unique_cstr);
|
||||
iterator end = m_map.end();
|
||||
|
@ -97,12 +97,14 @@ size_t Stream::PutULEB128(uint64_t uval) {
|
||||
//------------------------------------------------------------------
|
||||
// Print a raw NULL terminated C string to the stream.
|
||||
//------------------------------------------------------------------
|
||||
size_t Stream::PutCString(const char *cstr) {
|
||||
size_t cstr_len = strlen(cstr);
|
||||
size_t Stream::PutCString(llvm::StringRef str) {
|
||||
size_t bytes_written = 0;
|
||||
bytes_written = Write(str.data(), str.size());
|
||||
|
||||
// when in binary mode, emit the NULL terminator
|
||||
if (m_flags.Test(eBinary))
|
||||
++cstr_len;
|
||||
return Write(cstr, cstr_len);
|
||||
bytes_written += PutChar('\0');
|
||||
return bytes_written;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
|
@ -59,7 +59,7 @@ Error OptionValueEnumeration::SetValueFromString(llvm::StringRef value,
|
||||
ConstString const_enumerator_name(value.trim());
|
||||
const EnumerationMapEntry *enumerator_entry =
|
||||
m_enumerations.FindFirstValueForName(
|
||||
const_enumerator_name.GetCString());
|
||||
const_enumerator_name.GetStringRef());
|
||||
if (enumerator_entry) {
|
||||
m_current_value = enumerator_entry->value.value;
|
||||
NotifyValueChanged();
|
||||
@ -69,9 +69,10 @@ Error OptionValueEnumeration::SetValueFromString(llvm::StringRef value,
|
||||
const size_t count = m_enumerations.GetSize();
|
||||
if (count) {
|
||||
error_strm.Printf(", valid values are: %s",
|
||||
m_enumerations.GetCStringAtIndex(0));
|
||||
m_enumerations.GetCStringAtIndex(0).str().c_str());
|
||||
for (size_t i = 1; i < count; ++i) {
|
||||
error_strm.Printf(", %s", m_enumerations.GetCStringAtIndex(i));
|
||||
error_strm.Printf(", %s",
|
||||
m_enumerations.GetCStringAtIndex(i).str().c_str());
|
||||
}
|
||||
}
|
||||
error.SetErrorString(error_strm.GetData());
|
||||
@ -98,7 +99,7 @@ void OptionValueEnumeration::SetEnumerations(
|
||||
ConstString const_enumerator_name(enumerators[i].string_value);
|
||||
EnumeratorInfo enumerator_info = {enumerators[i].value,
|
||||
enumerators[i].usage};
|
||||
m_enumerations.Append(const_enumerator_name.GetCString(),
|
||||
m_enumerations.Append(const_enumerator_name.GetStringRef(),
|
||||
enumerator_info);
|
||||
}
|
||||
m_enumerations.Sort();
|
||||
@ -119,8 +120,8 @@ size_t OptionValueEnumeration::AutoComplete(
|
||||
if (s && s[0]) {
|
||||
const size_t s_len = strlen(s);
|
||||
for (size_t i = 0; i < num_enumerators; ++i) {
|
||||
const char *name = m_enumerations.GetCStringAtIndex(i);
|
||||
if (::strncmp(s, name, s_len) == 0)
|
||||
llvm::StringRef name = m_enumerations.GetCStringAtIndex(i);
|
||||
if (name.startswith(s))
|
||||
matches.AppendString(name);
|
||||
}
|
||||
} else {
|
||||
|
@ -59,7 +59,7 @@ void OptionValueProperties::Initialize(const PropertyDefinition *defs) {
|
||||
for (size_t i = 0; defs[i].name; ++i) {
|
||||
Property property(defs[i]);
|
||||
assert(property.IsValid());
|
||||
m_name_to_index.Append(property.GetName().GetCString(),
|
||||
m_name_to_index.Append(property.GetName().GetStringRef(),
|
||||
m_properties.size());
|
||||
property.GetValue()->SetParent(shared_from_this());
|
||||
m_properties.push_back(property);
|
||||
@ -79,7 +79,7 @@ void OptionValueProperties::AppendProperty(const ConstString &name,
|
||||
bool is_global,
|
||||
const OptionValueSP &value_sp) {
|
||||
Property property(name, desc, is_global, value_sp);
|
||||
m_name_to_index.Append(name.GetCString(), m_properties.size());
|
||||
m_name_to_index.Append(name.GetStringRef(), m_properties.size());
|
||||
m_properties.push_back(property);
|
||||
value_sp->SetParent(shared_from_this());
|
||||
m_name_to_index.Sort();
|
||||
@ -109,7 +109,7 @@ OptionValueProperties::GetValueForKey(const ExecutionContext *exe_ctx,
|
||||
const ConstString &key,
|
||||
bool will_modify) const {
|
||||
lldb::OptionValueSP value_sp;
|
||||
size_t idx = m_name_to_index.Find(key.GetCString(), SIZE_MAX);
|
||||
size_t idx = m_name_to_index.Find(key.GetStringRef(), SIZE_MAX);
|
||||
if (idx < m_properties.size())
|
||||
value_sp = GetPropertyAtIndex(exe_ctx, will_modify, idx)->GetValue();
|
||||
return value_sp;
|
||||
@ -234,15 +234,16 @@ OptionValueProperties::GetPropertyDescriptionAtIndex(uint32_t idx) const {
|
||||
|
||||
uint32_t
|
||||
OptionValueProperties::GetPropertyIndex(const ConstString &name) const {
|
||||
return m_name_to_index.Find(name.GetCString(), SIZE_MAX);
|
||||
return m_name_to_index.Find(name.GetStringRef(), SIZE_MAX);
|
||||
}
|
||||
|
||||
const Property *
|
||||
OptionValueProperties::GetProperty(const ExecutionContext *exe_ctx,
|
||||
bool will_modify,
|
||||
const ConstString &name) const {
|
||||
return GetPropertyAtIndex(exe_ctx, will_modify,
|
||||
m_name_to_index.Find(name.GetCString(), SIZE_MAX));
|
||||
return GetPropertyAtIndex(
|
||||
exe_ctx, will_modify,
|
||||
m_name_to_index.Find(name.GetStringRef(), SIZE_MAX));
|
||||
}
|
||||
|
||||
const Property *OptionValueProperties::GetPropertyAtIndex(
|
||||
|
@ -307,28 +307,29 @@ public:
|
||||
CPPRuntimeEquivalents() {
|
||||
m_impl.Append(ConstString("std::basic_string<char, std::char_traits<char>, "
|
||||
"std::allocator<char> >")
|
||||
.AsCString(),
|
||||
.GetStringRef(),
|
||||
ConstString("basic_string<char>"));
|
||||
|
||||
// these two (with a prefixed std::) occur when c++stdlib string class
|
||||
// occurs as a template argument in some STL container
|
||||
m_impl.Append(ConstString("std::basic_string<char, std::char_traits<char>, "
|
||||
"std::allocator<char> >")
|
||||
.AsCString(),
|
||||
.GetStringRef(),
|
||||
ConstString("std::basic_string<char>"));
|
||||
|
||||
m_impl.Sort();
|
||||
}
|
||||
|
||||
void Add(ConstString &type_name, ConstString &type_equivalent) {
|
||||
m_impl.Insert(type_name.AsCString(), type_equivalent);
|
||||
m_impl.Insert(type_name.GetStringRef(), type_equivalent);
|
||||
}
|
||||
|
||||
uint32_t FindExactMatches(ConstString &type_name,
|
||||
std::vector<ConstString> &equivalents) {
|
||||
uint32_t count = 0;
|
||||
|
||||
for (ImplData match = m_impl.FindFirstValueForName(type_name.AsCString());
|
||||
for (ImplData match =
|
||||
m_impl.FindFirstValueForName(type_name.GetStringRef());
|
||||
match != nullptr; match = m_impl.FindNextValueForName(match)) {
|
||||
equivalents.push_back(match->value);
|
||||
count++;
|
||||
@ -351,13 +352,13 @@ public:
|
||||
std::vector<ConstString> &equivalents) {
|
||||
uint32_t count = 0;
|
||||
|
||||
const char *type_name_cstr = type_name.AsCString();
|
||||
llvm::StringRef type_name_cstr = type_name.GetStringRef();
|
||||
|
||||
size_t items_count = m_impl.GetSize();
|
||||
|
||||
for (size_t item = 0; item < items_count; item++) {
|
||||
const char *key_cstr = m_impl.GetCStringAtIndex(item);
|
||||
if (strstr(type_name_cstr, key_cstr)) {
|
||||
llvm::StringRef key_cstr = m_impl.GetCStringAtIndex(item);
|
||||
if (type_name_cstr.contains(key_cstr)) {
|
||||
count += AppendReplacements(type_name_cstr, key_cstr, equivalents);
|
||||
}
|
||||
}
|
||||
@ -377,7 +378,8 @@ private:
|
||||
return target;
|
||||
}
|
||||
|
||||
uint32_t AppendReplacements(const char *original, const char *matching_key,
|
||||
uint32_t AppendReplacements(llvm::StringRef original,
|
||||
llvm::StringRef matching_key,
|
||||
std::vector<ConstString> &equivalents) {
|
||||
std::string matching_key_str(matching_key);
|
||||
ConstString original_const(original);
|
||||
|
@ -83,41 +83,46 @@ void ObjCLanguage::MethodName::Clear() {
|
||||
m_category_is_valid = false;
|
||||
}
|
||||
|
||||
bool ObjCLanguage::MethodName::SetName(const char *name, bool strict) {
|
||||
bool ObjCLanguage::MethodName::SetName(llvm::StringRef name, bool strict) {
|
||||
Clear();
|
||||
if (name && name[0]) {
|
||||
// If "strict" is true. then the method must be specified with a
|
||||
// '+' or '-' at the beginning. If "strict" is false, then the '+'
|
||||
// or '-' can be omitted
|
||||
bool valid_prefix = false;
|
||||
if (name.empty())
|
||||
return IsValid(strict);
|
||||
|
||||
if (name[0] == '+' || name[0] == '-') {
|
||||
valid_prefix = name[1] == '[';
|
||||
if (name[0] == '+')
|
||||
m_type = eTypeClassMethod;
|
||||
else
|
||||
m_type = eTypeInstanceMethod;
|
||||
} else if (!strict) {
|
||||
// "strict" is false, the name just needs to start with '['
|
||||
valid_prefix = name[0] == '[';
|
||||
}
|
||||
// If "strict" is true. then the method must be specified with a
|
||||
// '+' or '-' at the beginning. If "strict" is false, then the '+'
|
||||
// or '-' can be omitted
|
||||
bool valid_prefix = false;
|
||||
|
||||
if (valid_prefix) {
|
||||
int name_len = strlen(name);
|
||||
// Objective C methods must have at least:
|
||||
// "-[" or "+[" prefix
|
||||
// One character for a class name
|
||||
// One character for the space between the class name
|
||||
// One character for the method name
|
||||
// "]" suffix
|
||||
if (name_len >= (5 + (strict ? 1 : 0)) && name[name_len - 1] == ']') {
|
||||
m_full.SetCStringWithLength(name, name_len);
|
||||
}
|
||||
if (name[0] == '+' || name[0] == '-') {
|
||||
valid_prefix = name[1] == '[';
|
||||
if (name[0] == '+')
|
||||
m_type = eTypeClassMethod;
|
||||
else
|
||||
m_type = eTypeInstanceMethod;
|
||||
} else if (!strict) {
|
||||
// "strict" is false, the name just needs to start with '['
|
||||
valid_prefix = name[0] == '[';
|
||||
}
|
||||
|
||||
if (valid_prefix) {
|
||||
int name_len = name.size();
|
||||
// Objective C methods must have at least:
|
||||
// "-[" or "+[" prefix
|
||||
// One character for a class name
|
||||
// One character for the space between the class name
|
||||
// One character for the method name
|
||||
// "]" suffix
|
||||
if (name_len >= (5 + (strict ? 1 : 0)) && name.back() == ']') {
|
||||
m_full.SetString(name);
|
||||
}
|
||||
}
|
||||
return IsValid(strict);
|
||||
}
|
||||
|
||||
bool ObjCLanguage::MethodName::SetName(const char *name, bool strict) {
|
||||
return SetName(llvm::StringRef(name), strict);
|
||||
}
|
||||
|
||||
const ConstString &ObjCLanguage::MethodName::GetClassName() {
|
||||
if (!m_class) {
|
||||
if (IsValid(false)) {
|
||||
|
@ -38,6 +38,11 @@ public:
|
||||
m_type(eTypeUnspecified), m_category_is_valid(false) {
|
||||
SetName(name, strict);
|
||||
}
|
||||
MethodName(llvm::StringRef name, bool strict)
|
||||
: m_full(), m_class(), m_category(), m_selector(),
|
||||
m_type(eTypeUnspecified), m_category_is_valid(false) {
|
||||
SetName(name, strict);
|
||||
}
|
||||
|
||||
void Clear();
|
||||
|
||||
@ -60,6 +65,7 @@ public:
|
||||
ConstString GetFullNameWithoutCategory(bool empty_if_no_category);
|
||||
|
||||
bool SetName(const char *name, bool strict);
|
||||
bool SetName(llvm::StringRef name, bool strict);
|
||||
|
||||
const ConstString &GetClassName();
|
||||
|
||||
|
@ -155,7 +155,7 @@ size_t ObjectContainerBSDArchive::Archive::ParseObjects() {
|
||||
size_t obj_idx = m_objects.size();
|
||||
m_objects.push_back(obj);
|
||||
// Insert all of the C strings out of order for now...
|
||||
m_object_name_to_index_map.Append(obj.ar_name.GetCString(), obj_idx);
|
||||
m_object_name_to_index_map.Append(obj.ar_name.GetStringRef(), obj_idx);
|
||||
offset += obj.ar_file_size;
|
||||
obj.Clear();
|
||||
} while (data.ValidOffset(offset));
|
||||
@ -171,7 +171,7 @@ ObjectContainerBSDArchive::Archive::FindObject(
|
||||
const ConstString &object_name, const TimeValue &object_mod_time) {
|
||||
const ObjectNameToIndexMap::Entry *match =
|
||||
m_object_name_to_index_map.FindFirstValueForName(
|
||||
object_name.GetCString());
|
||||
object_name.GetStringRef());
|
||||
if (match) {
|
||||
if (object_mod_time.IsValid()) {
|
||||
const uint64_t object_date = object_mod_time.GetAsSecondsSinceJan1_1970();
|
||||
|
@ -3840,10 +3840,10 @@ bool DWARFASTParserClang::CopyUniqueClassMethodTypes(
|
||||
if (src_name) {
|
||||
ConstString src_const_name(src_name);
|
||||
if (src_die.GetAttributeValueAsUnsigned(DW_AT_artificial, 0))
|
||||
src_name_to_die_artificial.Append(src_const_name.GetCString(),
|
||||
src_name_to_die_artificial.Append(src_const_name.GetStringRef(),
|
||||
src_die);
|
||||
else
|
||||
src_name_to_die.Append(src_const_name.GetCString(), src_die);
|
||||
src_name_to_die.Append(src_const_name.GetStringRef(), src_die);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3860,10 +3860,10 @@ bool DWARFASTParserClang::CopyUniqueClassMethodTypes(
|
||||
if (dst_name) {
|
||||
ConstString dst_const_name(dst_name);
|
||||
if (dst_die.GetAttributeValueAsUnsigned(DW_AT_artificial, 0))
|
||||
dst_name_to_die_artificial.Append(dst_const_name.GetCString(),
|
||||
dst_name_to_die_artificial.Append(dst_const_name.GetStringRef(),
|
||||
dst_die);
|
||||
else
|
||||
dst_name_to_die.Append(dst_const_name.GetCString(), dst_die);
|
||||
dst_name_to_die.Append(dst_const_name.GetStringRef(), dst_die);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3976,7 +3976,7 @@ bool DWARFASTParserClang::CopyUniqueClassMethodTypes(
|
||||
src_name_to_die.Sort();
|
||||
|
||||
for (idx = 0; idx < dst_size; ++idx) {
|
||||
const char *dst_name = dst_name_to_die.GetCStringAtIndex(idx);
|
||||
llvm::StringRef dst_name = dst_name_to_die.GetCStringAtIndex(idx);
|
||||
dst_die = dst_name_to_die.GetValueAtIndexUnchecked(idx);
|
||||
src_die = src_name_to_die.Find(dst_name, DWARFDIE());
|
||||
|
||||
@ -4031,7 +4031,7 @@ bool DWARFASTParserClang::CopyUniqueClassMethodTypes(
|
||||
dst_name_to_die_artificial.Sort();
|
||||
|
||||
for (idx = 0; idx < src_size_artificial; ++idx) {
|
||||
const char *src_name_artificial =
|
||||
llvm::StringRef src_name_artificial =
|
||||
src_name_to_die_artificial.GetCStringAtIndex(idx);
|
||||
src_die = src_name_to_die_artificial.GetValueAtIndexUnchecked(idx);
|
||||
dst_die =
|
||||
@ -4075,7 +4075,7 @@ bool DWARFASTParserClang::CopyUniqueClassMethodTypes(
|
||||
|
||||
if (dst_size_artificial) {
|
||||
for (idx = 0; idx < dst_size_artificial; ++idx) {
|
||||
const char *dst_name_artificial =
|
||||
llvm::StringRef dst_name_artificial =
|
||||
dst_name_to_die_artificial.GetCStringAtIndex(idx);
|
||||
dst_die = dst_name_to_die_artificial.GetValueAtIndexUnchecked(idx);
|
||||
if (log)
|
||||
|
@ -28,11 +28,11 @@ void NameToDIE::Finalize() {
|
||||
}
|
||||
|
||||
void NameToDIE::Insert(const ConstString &name, const DIERef &die_ref) {
|
||||
m_map.Append(name.GetCString(), die_ref);
|
||||
m_map.Append(name.GetStringRef(), die_ref);
|
||||
}
|
||||
|
||||
size_t NameToDIE::Find(const ConstString &name, DIEArray &info_array) const {
|
||||
return m_map.GetValues(name.GetCString(), info_array);
|
||||
return m_map.GetValues(name.GetStringRef(), info_array);
|
||||
}
|
||||
|
||||
size_t NameToDIE::Find(const RegularExpression ®ex,
|
||||
@ -55,15 +55,15 @@ size_t NameToDIE::FindAllEntriesForCompileUnit(dw_offset_t cu_offset,
|
||||
void NameToDIE::Dump(Stream *s) {
|
||||
const uint32_t size = m_map.GetSize();
|
||||
for (uint32_t i = 0; i < size; ++i) {
|
||||
const char *cstr = m_map.GetCStringAtIndex(i);
|
||||
llvm::StringRef cstr = m_map.GetCStringAtIndex(i);
|
||||
const DIERef &die_ref = m_map.GetValueAtIndexUnchecked(i);
|
||||
s->Printf("%p: {0x%8.8x/0x%8.8x} \"%s\"\n", (const void *)cstr,
|
||||
s->Printf("%p: {0x%8.8x/0x%8.8x} \"%s\"\n", (const void *)cstr.data(),
|
||||
die_ref.cu_offset, die_ref.die_offset, cstr);
|
||||
}
|
||||
}
|
||||
|
||||
void NameToDIE::ForEach(
|
||||
std::function<bool(const char *name, const DIERef &die_ref)> const
|
||||
std::function<bool(llvm::StringRef name, const DIERef &die_ref)> const
|
||||
&callback) const {
|
||||
const uint32_t size = m_map.GetSize();
|
||||
for (uint32_t i = 0; i < size; ++i) {
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
DIEArray &info_array) const;
|
||||
|
||||
void
|
||||
ForEach(std::function<bool(const char *name, const DIERef &die_ref)> const
|
||||
ForEach(std::function<bool(llvm::StringRef name, const DIERef &die_ref)> const
|
||||
&callback) const;
|
||||
|
||||
protected:
|
||||
|
@ -952,72 +952,75 @@ ClangASTContext::GetBasicTypeEnumeration(const ConstString &name) {
|
||||
static std::once_flag g_once_flag;
|
||||
std::call_once(g_once_flag, []() {
|
||||
// "void"
|
||||
g_type_map.Append(ConstString("void").GetCString(), eBasicTypeVoid);
|
||||
g_type_map.Append(ConstString("void").GetStringRef(), eBasicTypeVoid);
|
||||
|
||||
// "char"
|
||||
g_type_map.Append(ConstString("char").GetCString(), eBasicTypeChar);
|
||||
g_type_map.Append(ConstString("signed char").GetCString(),
|
||||
g_type_map.Append(ConstString("char").GetStringRef(), eBasicTypeChar);
|
||||
g_type_map.Append(ConstString("signed char").GetStringRef(),
|
||||
eBasicTypeSignedChar);
|
||||
g_type_map.Append(ConstString("unsigned char").GetCString(),
|
||||
g_type_map.Append(ConstString("unsigned char").GetStringRef(),
|
||||
eBasicTypeUnsignedChar);
|
||||
g_type_map.Append(ConstString("wchar_t").GetCString(), eBasicTypeWChar);
|
||||
g_type_map.Append(ConstString("signed wchar_t").GetCString(),
|
||||
g_type_map.Append(ConstString("wchar_t").GetStringRef(), eBasicTypeWChar);
|
||||
g_type_map.Append(ConstString("signed wchar_t").GetStringRef(),
|
||||
eBasicTypeSignedWChar);
|
||||
g_type_map.Append(ConstString("unsigned wchar_t").GetCString(),
|
||||
g_type_map.Append(ConstString("unsigned wchar_t").GetStringRef(),
|
||||
eBasicTypeUnsignedWChar);
|
||||
// "short"
|
||||
g_type_map.Append(ConstString("short").GetCString(), eBasicTypeShort);
|
||||
g_type_map.Append(ConstString("short int").GetCString(), eBasicTypeShort);
|
||||
g_type_map.Append(ConstString("unsigned short").GetCString(),
|
||||
g_type_map.Append(ConstString("short").GetStringRef(), eBasicTypeShort);
|
||||
g_type_map.Append(ConstString("short int").GetStringRef(),
|
||||
eBasicTypeShort);
|
||||
g_type_map.Append(ConstString("unsigned short").GetStringRef(),
|
||||
eBasicTypeUnsignedShort);
|
||||
g_type_map.Append(ConstString("unsigned short int").GetCString(),
|
||||
g_type_map.Append(ConstString("unsigned short int").GetStringRef(),
|
||||
eBasicTypeUnsignedShort);
|
||||
|
||||
// "int"
|
||||
g_type_map.Append(ConstString("int").GetCString(), eBasicTypeInt);
|
||||
g_type_map.Append(ConstString("signed int").GetCString(), eBasicTypeInt);
|
||||
g_type_map.Append(ConstString("unsigned int").GetCString(),
|
||||
g_type_map.Append(ConstString("int").GetStringRef(), eBasicTypeInt);
|
||||
g_type_map.Append(ConstString("signed int").GetStringRef(),
|
||||
eBasicTypeInt);
|
||||
g_type_map.Append(ConstString("unsigned int").GetStringRef(),
|
||||
eBasicTypeUnsignedInt);
|
||||
g_type_map.Append(ConstString("unsigned").GetCString(),
|
||||
g_type_map.Append(ConstString("unsigned").GetStringRef(),
|
||||
eBasicTypeUnsignedInt);
|
||||
|
||||
// "long"
|
||||
g_type_map.Append(ConstString("long").GetCString(), eBasicTypeLong);
|
||||
g_type_map.Append(ConstString("long int").GetCString(), eBasicTypeLong);
|
||||
g_type_map.Append(ConstString("unsigned long").GetCString(),
|
||||
g_type_map.Append(ConstString("long").GetStringRef(), eBasicTypeLong);
|
||||
g_type_map.Append(ConstString("long int").GetStringRef(), eBasicTypeLong);
|
||||
g_type_map.Append(ConstString("unsigned long").GetStringRef(),
|
||||
eBasicTypeUnsignedLong);
|
||||
g_type_map.Append(ConstString("unsigned long int").GetCString(),
|
||||
g_type_map.Append(ConstString("unsigned long int").GetStringRef(),
|
||||
eBasicTypeUnsignedLong);
|
||||
|
||||
// "long long"
|
||||
g_type_map.Append(ConstString("long long").GetCString(),
|
||||
g_type_map.Append(ConstString("long long").GetStringRef(),
|
||||
eBasicTypeLongLong);
|
||||
g_type_map.Append(ConstString("long long int").GetCString(),
|
||||
g_type_map.Append(ConstString("long long int").GetStringRef(),
|
||||
eBasicTypeLongLong);
|
||||
g_type_map.Append(ConstString("unsigned long long").GetCString(),
|
||||
g_type_map.Append(ConstString("unsigned long long").GetStringRef(),
|
||||
eBasicTypeUnsignedLongLong);
|
||||
g_type_map.Append(ConstString("unsigned long long int").GetCString(),
|
||||
g_type_map.Append(ConstString("unsigned long long int").GetStringRef(),
|
||||
eBasicTypeUnsignedLongLong);
|
||||
|
||||
// "int128"
|
||||
g_type_map.Append(ConstString("__int128_t").GetCString(),
|
||||
g_type_map.Append(ConstString("__int128_t").GetStringRef(),
|
||||
eBasicTypeInt128);
|
||||
g_type_map.Append(ConstString("__uint128_t").GetCString(),
|
||||
g_type_map.Append(ConstString("__uint128_t").GetStringRef(),
|
||||
eBasicTypeUnsignedInt128);
|
||||
|
||||
// Miscellaneous
|
||||
g_type_map.Append(ConstString("bool").GetCString(), eBasicTypeBool);
|
||||
g_type_map.Append(ConstString("float").GetCString(), eBasicTypeFloat);
|
||||
g_type_map.Append(ConstString("double").GetCString(), eBasicTypeDouble);
|
||||
g_type_map.Append(ConstString("long double").GetCString(),
|
||||
g_type_map.Append(ConstString("bool").GetStringRef(), eBasicTypeBool);
|
||||
g_type_map.Append(ConstString("float").GetStringRef(), eBasicTypeFloat);
|
||||
g_type_map.Append(ConstString("double").GetStringRef(), eBasicTypeDouble);
|
||||
g_type_map.Append(ConstString("long double").GetStringRef(),
|
||||
eBasicTypeLongDouble);
|
||||
g_type_map.Append(ConstString("id").GetCString(), eBasicTypeObjCID);
|
||||
g_type_map.Append(ConstString("SEL").GetCString(), eBasicTypeObjCSel);
|
||||
g_type_map.Append(ConstString("nullptr").GetCString(), eBasicTypeNullPtr);
|
||||
g_type_map.Append(ConstString("id").GetStringRef(), eBasicTypeObjCID);
|
||||
g_type_map.Append(ConstString("SEL").GetStringRef(), eBasicTypeObjCSel);
|
||||
g_type_map.Append(ConstString("nullptr").GetStringRef(),
|
||||
eBasicTypeNullPtr);
|
||||
g_type_map.Sort();
|
||||
});
|
||||
|
||||
return g_type_map.Find(name.GetCString(), eBasicTypeInvalid);
|
||||
return g_type_map.Find(name.GetStringRef(), eBasicTypeInvalid);
|
||||
}
|
||||
return eBasicTypeInvalid;
|
||||
}
|
||||
|
@ -596,33 +596,33 @@ GoASTContext::GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) {
|
||||
static std::once_flag g_once_flag;
|
||||
std::call_once(g_once_flag, []() {
|
||||
// "void"
|
||||
g_type_map.Append(ConstString("void").GetCString(), eBasicTypeVoid);
|
||||
g_type_map.Append(ConstString("void").GetStringRef(), eBasicTypeVoid);
|
||||
// "int"
|
||||
g_type_map.Append(ConstString("int").GetCString(), eBasicTypeInt);
|
||||
g_type_map.Append(ConstString("uint").GetCString(),
|
||||
g_type_map.Append(ConstString("int").GetStringRef(), eBasicTypeInt);
|
||||
g_type_map.Append(ConstString("uint").GetStringRef(),
|
||||
eBasicTypeUnsignedInt);
|
||||
|
||||
// Miscellaneous
|
||||
g_type_map.Append(ConstString("bool").GetCString(), eBasicTypeBool);
|
||||
g_type_map.Append(ConstString("bool").GetStringRef(), eBasicTypeBool);
|
||||
|
||||
// Others. Should these map to C types?
|
||||
g_type_map.Append(ConstString("byte").GetCString(), eBasicTypeOther);
|
||||
g_type_map.Append(ConstString("uint8").GetCString(), eBasicTypeOther);
|
||||
g_type_map.Append(ConstString("uint16").GetCString(), eBasicTypeOther);
|
||||
g_type_map.Append(ConstString("uint32").GetCString(), eBasicTypeOther);
|
||||
g_type_map.Append(ConstString("uint64").GetCString(), eBasicTypeOther);
|
||||
g_type_map.Append(ConstString("int8").GetCString(), eBasicTypeOther);
|
||||
g_type_map.Append(ConstString("int16").GetCString(), eBasicTypeOther);
|
||||
g_type_map.Append(ConstString("int32").GetCString(), eBasicTypeOther);
|
||||
g_type_map.Append(ConstString("int64").GetCString(), eBasicTypeOther);
|
||||
g_type_map.Append(ConstString("float32").GetCString(), eBasicTypeOther);
|
||||
g_type_map.Append(ConstString("float64").GetCString(), eBasicTypeOther);
|
||||
g_type_map.Append(ConstString("uintptr").GetCString(), eBasicTypeOther);
|
||||
g_type_map.Append(ConstString("byte").GetStringRef(), eBasicTypeOther);
|
||||
g_type_map.Append(ConstString("uint8").GetStringRef(), eBasicTypeOther);
|
||||
g_type_map.Append(ConstString("uint16").GetStringRef(), eBasicTypeOther);
|
||||
g_type_map.Append(ConstString("uint32").GetStringRef(), eBasicTypeOther);
|
||||
g_type_map.Append(ConstString("uint64").GetStringRef(), eBasicTypeOther);
|
||||
g_type_map.Append(ConstString("int8").GetStringRef(), eBasicTypeOther);
|
||||
g_type_map.Append(ConstString("int16").GetStringRef(), eBasicTypeOther);
|
||||
g_type_map.Append(ConstString("int32").GetStringRef(), eBasicTypeOther);
|
||||
g_type_map.Append(ConstString("int64").GetStringRef(), eBasicTypeOther);
|
||||
g_type_map.Append(ConstString("float32").GetStringRef(), eBasicTypeOther);
|
||||
g_type_map.Append(ConstString("float64").GetStringRef(), eBasicTypeOther);
|
||||
g_type_map.Append(ConstString("uintptr").GetStringRef(), eBasicTypeOther);
|
||||
|
||||
g_type_map.Sort();
|
||||
});
|
||||
|
||||
return g_type_map.Find(name.GetCString(), eBasicTypeInvalid);
|
||||
return g_type_map.Find(name.GetStringRef(), eBasicTypeInvalid);
|
||||
}
|
||||
return eBasicTypeInvalid;
|
||||
}
|
||||
|
@ -262,17 +262,16 @@ void Symtab::InitNameIndexes() {
|
||||
continue;
|
||||
|
||||
const Mangled &mangled = symbol->GetMangled();
|
||||
entry.cstring = mangled.GetMangledName().GetCString();
|
||||
if (entry.cstring && entry.cstring[0]) {
|
||||
entry.cstring = mangled.GetMangledName().GetStringRef();
|
||||
if (!entry.cstring.empty()) {
|
||||
m_name_to_index.Append(entry);
|
||||
|
||||
if (symbol->ContainsLinkerAnnotations()) {
|
||||
// If the symbol has linker annotations, also add the version without
|
||||
// the
|
||||
// annotations.
|
||||
// the annotations.
|
||||
entry.cstring = ConstString(m_objfile->StripLinkerSymbolAnnotations(
|
||||
entry.cstring))
|
||||
.GetCString();
|
||||
.GetStringRef();
|
||||
m_name_to_index.Append(entry);
|
||||
}
|
||||
|
||||
@ -290,8 +289,9 @@ void Symtab::InitNameIndexes() {
|
||||
{
|
||||
CPlusPlusLanguage::MethodName cxx_method(
|
||||
mangled.GetDemangledName(lldb::eLanguageTypeC_plus_plus));
|
||||
entry.cstring = ConstString(cxx_method.GetBasename()).GetCString();
|
||||
if (entry.cstring && entry.cstring[0]) {
|
||||
entry.cstring =
|
||||
ConstString(cxx_method.GetBasename()).GetStringRef();
|
||||
if (!entry.cstring.empty()) {
|
||||
// ConstString objects permanently store the string in the pool so
|
||||
// calling
|
||||
// GetCString() on the value gets us a const char * that will
|
||||
@ -336,17 +336,16 @@ void Symtab::InitNameIndexes() {
|
||||
}
|
||||
|
||||
entry.cstring =
|
||||
mangled.GetDemangledName(symbol->GetLanguage()).GetCString();
|
||||
if (entry.cstring && entry.cstring[0]) {
|
||||
mangled.GetDemangledName(symbol->GetLanguage()).GetStringRef();
|
||||
if (!entry.cstring.empty()) {
|
||||
m_name_to_index.Append(entry);
|
||||
|
||||
if (symbol->ContainsLinkerAnnotations()) {
|
||||
// If the symbol has linker annotations, also add the version without
|
||||
// the
|
||||
// annotations.
|
||||
// the annotations.
|
||||
entry.cstring = ConstString(m_objfile->StripLinkerSymbolAnnotations(
|
||||
entry.cstring))
|
||||
.GetCString();
|
||||
.GetStringRef();
|
||||
m_name_to_index.Append(entry);
|
||||
}
|
||||
}
|
||||
@ -356,13 +355,13 @@ void Symtab::InitNameIndexes() {
|
||||
// too.
|
||||
ObjCLanguage::MethodName objc_method(entry.cstring, true);
|
||||
if (objc_method.IsValid(true)) {
|
||||
entry.cstring = objc_method.GetSelector().GetCString();
|
||||
entry.cstring = objc_method.GetSelector().GetStringRef();
|
||||
m_selector_to_index.Append(entry);
|
||||
|
||||
ConstString objc_method_no_category(
|
||||
objc_method.GetFullNameWithoutCategory(true));
|
||||
if (objc_method_no_category) {
|
||||
entry.cstring = objc_method_no_category.GetCString();
|
||||
entry.cstring = objc_method_no_category.GetStringRef();
|
||||
m_name_to_index.Append(entry);
|
||||
}
|
||||
}
|
||||
@ -440,14 +439,14 @@ void Symtab::AppendSymbolNamesToMap(const IndexCollection &indexes,
|
||||
const Mangled &mangled = symbol->GetMangled();
|
||||
if (add_demangled) {
|
||||
entry.cstring =
|
||||
mangled.GetDemangledName(symbol->GetLanguage()).GetCString();
|
||||
if (entry.cstring && entry.cstring[0])
|
||||
mangled.GetDemangledName(symbol->GetLanguage()).GetStringRef();
|
||||
if (!entry.cstring.empty())
|
||||
name_to_index_map.Append(entry);
|
||||
}
|
||||
|
||||
if (add_mangled) {
|
||||
entry.cstring = mangled.GetMangledName().GetCString();
|
||||
if (entry.cstring && entry.cstring[0])
|
||||
entry.cstring = mangled.GetMangledName().GetStringRef();
|
||||
if (!entry.cstring.empty())
|
||||
name_to_index_map.Append(entry);
|
||||
}
|
||||
}
|
||||
@ -617,11 +616,10 @@ uint32_t Symtab::AppendSymbolIndexesWithName(const ConstString &symbol_name,
|
||||
|
||||
Timer scoped_timer(LLVM_PRETTY_FUNCTION, "%s", LLVM_PRETTY_FUNCTION);
|
||||
if (symbol_name) {
|
||||
const char *symbol_cstr = symbol_name.GetCString();
|
||||
if (!m_name_indexes_computed)
|
||||
InitNameIndexes();
|
||||
|
||||
return m_name_to_index.GetValues(symbol_cstr, indexes);
|
||||
return m_name_to_index.GetValues(symbol_name.GetStringRef(), indexes);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -638,11 +636,9 @@ uint32_t Symtab::AppendSymbolIndexesWithName(const ConstString &symbol_name,
|
||||
if (!m_name_indexes_computed)
|
||||
InitNameIndexes();
|
||||
|
||||
const char *symbol_cstr = symbol_name.GetCString();
|
||||
|
||||
std::vector<uint32_t> all_name_indexes;
|
||||
const size_t name_match_count =
|
||||
m_name_to_index.GetValues(symbol_cstr, all_name_indexes);
|
||||
m_name_to_index.GetValues(symbol_name.GetStringRef(), all_name_indexes);
|
||||
for (size_t i = 0; i < name_match_count; ++i) {
|
||||
if (CheckSymbolAtIndex(all_name_indexes[i], symbol_debug_type,
|
||||
symbol_visibility))
|
||||
@ -1066,7 +1062,7 @@ size_t Symtab::FindFunctionSymbols(const ConstString &name,
|
||||
size_t count = 0;
|
||||
std::vector<uint32_t> symbol_indexes;
|
||||
|
||||
const char *name_cstr = name.GetCString();
|
||||
llvm::StringRef name_cstr = name.GetStringRef();
|
||||
|
||||
// eFunctionNameTypeAuto should be pre-resolved by a call to
|
||||
// Module::LookupInfo::LookupInfo()
|
||||
|
Loading…
Reference in New Issue
Block a user