diff options
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 85bd53741e1..32c9b28124a 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -813,7 +813,11 @@ void CodeGenModule::UpdateMultiVersionNames(GlobalDecl GD, // This is so that if the initial version was already the 'default' // version, we don't try to update it. if (OtherName != NonTargetName) { - Manglings.erase(NonTargetName); + // Remove instead of erase, since others may have stored the StringRef + // to this. + const auto ExistingRecord = Manglings.find(NonTargetName); + if (ExistingRecord != std::end(Manglings)) + Manglings.remove(&(*ExistingRecord)); auto Result = Manglings.insert(std::make_pair(OtherName, OtherGD)); MangledDeclNames[OtherGD.getCanonicalDecl()] = Result.first->first(); if (llvm::GlobalValue *Entry = GetGlobalValue(NonTargetName)) |