summaryrefslogtreecommitdiffstats
path: root/lldb/source/Utility/ConstString.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Utility/ConstString.cpp')
-rw-r--r--lldb/source/Utility/ConstString.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/lldb/source/Utility/ConstString.cpp b/lldb/source/Utility/ConstString.cpp
index e903783df52..d4bfbcc7a64 100644
--- a/lldb/source/Utility/ConstString.cpp
+++ b/lldb/source/Utility/ConstString.cpp
@@ -119,11 +119,16 @@ public:
const uint8_t h = hash(demangled);
llvm::sys::SmartScopedWriter<false> wlock(m_string_pools[h].m_mutex);
- // Make string pool entry with the mangled counterpart already set
- StringPoolEntryType &entry =
- *m_string_pools[h]
- .m_string_map.insert(std::make_pair(demangled, mangled_ccstr))
- .first;
+ // Make or update string pool entry with the mangled counterpart
+ StringPool &map = m_string_pools[h].m_string_map;
+ StringPoolEntryType &entry = *map.try_emplace(demangled).first;
+
+ assert((entry.second == nullptr || entry.second == mangled_ccstr ||
+ strlen(entry.second) == 0) &&
+ "The demangled string must have a unique counterpart or otherwise "
+ "it must be empty");
+
+ entry.second = mangled_ccstr;
// Extract the const version of the demangled_cstr
demangled_ccstr = entry.getKeyData();
OpenPOWER on IntegriCloud