[lldb] Change ObjectValueDictionary to use a StringMap

llvm has a structure for maps where the key's type is a string. Using
that also means that the keys for OptionValueDictionary don't stick
around forever in ConstString's StringPool (even after they are gone).

The only thing we lose here is ordering: iterating over the map where the keys
are ConstStrings guarantees that we iterate in alphabetical order.
StringMap makes no guarantees about the ordering when you iterate over
the entire map.

Differential Revision: https://reviews.llvm.org/D149482
This commit is contained in:
Alex Langford
2023-04-28 13:23:55 -07:00
parent 2a333e9104
commit e53e1de57e
10 changed files with 52 additions and 59 deletions

View File

@@ -300,20 +300,18 @@ size_t ObjectFilePECOFF::GetModuleSpecifications(
if (!module_env_option) {
// Step 2: Try with the file name in lowercase.
auto name_lower = name.GetStringRef().lower();
module_env_option =
map->GetValueForKey(ConstString(llvm::StringRef(name_lower)));
module_env_option = map->GetValueForKey(llvm::StringRef(name_lower));
}
if (!module_env_option) {
// Step 3: Try with the file name with ".debug" suffix stripped.
auto name_stripped = name.GetStringRef();
if (name_stripped.consume_back_insensitive(".debug")) {
module_env_option = map->GetValueForKey(ConstString(name_stripped));
module_env_option = map->GetValueForKey(name_stripped);
if (!module_env_option) {
// Step 4: Try with the file name in lowercase with ".debug" suffix
// stripped.
auto name_lower = name_stripped.lower();
module_env_option =
map->GetValueForKey(ConstString(llvm::StringRef(name_lower)));
module_env_option = map->GetValueForKey(llvm::StringRef(name_lower));
}
}
}