diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h --- a/lldb/include/lldb/Symbol/CompilerType.h +++ b/lldb/include/lldb/Symbol/CompilerType.h @@ -344,8 +344,6 @@ lldb::BasicType GetBasicTypeEnumeration() const; - static lldb::BasicType GetBasicTypeEnumeration(ConstString name); - /// If this type is an enumeration, iterate through all of its enumerators /// using a callback. If the callback returns true, keep iterating, else abort /// the iteration. diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -207,7 +207,7 @@ CompilerType GetBasicType(lldb::BasicType type); - static lldb::BasicType GetBasicTypeEnumeration(ConstString name); + static lldb::BasicType GetBasicTypeEnumeration(llvm::StringRef name); CompilerType GetBuiltinTypeForDWARFEncodingAndBitSize(llvm::StringRef type_name, @@ -834,10 +834,6 @@ lldb::BasicType GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) override; - static lldb::BasicType - GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type, - ConstString name); - void ForEachEnumerator( lldb::opaque_compiler_type_t type, std::function TypeNameToBasicTypeMap; - static TypeNameToBasicTypeMap g_type_map; - static llvm::once_flag g_once_flag; - llvm::call_once(g_once_flag, []() { +lldb::BasicType TypeSystemClang::GetBasicTypeEnumeration(llvm::StringRef name) { + static const llvm::StringMap g_type_map = { // "void" - g_type_map.Append(ConstString("void"), eBasicTypeVoid); + {"void", eBasicTypeVoid}, // "char" - g_type_map.Append(ConstString("char"), eBasicTypeChar); - g_type_map.Append(ConstString("signed char"), eBasicTypeSignedChar); - g_type_map.Append(ConstString("unsigned char"), eBasicTypeUnsignedChar); - g_type_map.Append(ConstString("wchar_t"), eBasicTypeWChar); - g_type_map.Append(ConstString("signed wchar_t"), eBasicTypeSignedWChar); - g_type_map.Append(ConstString("unsigned wchar_t"), - eBasicTypeUnsignedWChar); + {"char", eBasicTypeChar}, + {"signed char", eBasicTypeSignedChar}, + {"unsigned char", eBasicTypeUnsignedChar}, + {"wchar_t", eBasicTypeWChar}, + {"signed wchar_t", eBasicTypeSignedWChar}, + {"unsigned wchar_t", eBasicTypeUnsignedWChar}, + // "short" - g_type_map.Append(ConstString("short"), eBasicTypeShort); - g_type_map.Append(ConstString("short int"), eBasicTypeShort); - g_type_map.Append(ConstString("unsigned short"), eBasicTypeUnsignedShort); - g_type_map.Append(ConstString("unsigned short int"), - eBasicTypeUnsignedShort); + {"short", eBasicTypeShort}, + {"short int", eBasicTypeShort}, + {"unsigned short", eBasicTypeUnsignedShort}, + {"unsigned short int", eBasicTypeUnsignedShort}, // "int" - g_type_map.Append(ConstString("int"), eBasicTypeInt); - g_type_map.Append(ConstString("signed int"), eBasicTypeInt); - g_type_map.Append(ConstString("unsigned int"), eBasicTypeUnsignedInt); - g_type_map.Append(ConstString("unsigned"), eBasicTypeUnsignedInt); + {"int", eBasicTypeInt}, + {"signed int", eBasicTypeInt}, + {"unsigned int", eBasicTypeUnsignedInt}, + {"unsigned", eBasicTypeUnsignedInt}, // "long" - g_type_map.Append(ConstString("long"), eBasicTypeLong); - g_type_map.Append(ConstString("long int"), eBasicTypeLong); - g_type_map.Append(ConstString("unsigned long"), eBasicTypeUnsignedLong); - g_type_map.Append(ConstString("unsigned long int"), - eBasicTypeUnsignedLong); + {"long", eBasicTypeLong}, + {"long int", eBasicTypeLong}, + {"unsigned long", eBasicTypeUnsignedLong}, + {"unsigned long int", eBasicTypeUnsignedLong}, // "long long" - g_type_map.Append(ConstString("long long"), eBasicTypeLongLong); - g_type_map.Append(ConstString("long long int"), eBasicTypeLongLong); - g_type_map.Append(ConstString("unsigned long long"), - eBasicTypeUnsignedLongLong); - g_type_map.Append(ConstString("unsigned long long int"), - eBasicTypeUnsignedLongLong); + {"long long", eBasicTypeLongLong}, + {"long long int", eBasicTypeLongLong}, + {"unsigned long long", eBasicTypeUnsignedLongLong}, + {"unsigned long long int", eBasicTypeUnsignedLongLong}, // "int128" - g_type_map.Append(ConstString("__int128_t"), eBasicTypeInt128); - g_type_map.Append(ConstString("__uint128_t"), eBasicTypeUnsignedInt128); + {"__int128_t", eBasicTypeInt128}, + {"__uint128_t", eBasicTypeUnsignedInt128}, // Miscellaneous - g_type_map.Append(ConstString("bool"), eBasicTypeBool); - g_type_map.Append(ConstString("float"), eBasicTypeFloat); - g_type_map.Append(ConstString("double"), eBasicTypeDouble); - g_type_map.Append(ConstString("long double"), eBasicTypeLongDouble); - g_type_map.Append(ConstString("id"), eBasicTypeObjCID); - g_type_map.Append(ConstString("SEL"), eBasicTypeObjCSel); - g_type_map.Append(ConstString("nullptr"), eBasicTypeNullPtr); - g_type_map.Sort(); - }); - - return g_type_map.Find(name, eBasicTypeInvalid); - } - return eBasicTypeInvalid; + {"bool", eBasicTypeBool}, + {"float", eBasicTypeFloat}, + {"double", eBasicTypeDouble}, + {"long double", eBasicTypeLongDouble}, + {"id", eBasicTypeObjCID}, + {"SEL", eBasicTypeObjCSel}, + {"nullptr", eBasicTypeNullPtr}, + }; + + auto iter = g_type_map.find(name); + if (iter == g_type_map.end()) + return eBasicTypeInvalid; + + return iter->second; } uint32_t TypeSystemClang::GetPointerByteSize() {