summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorNAKAMURA Takumi <geek4civic@gmail.com>2017-07-30 05:06:26 +0000
committerNAKAMURA Takumi <geek4civic@gmail.com>2017-07-30 05:06:26 +0000
commit6e4d774b02ae424fcc3ba4a6d35be6348c851f46 (patch)
tree2aea1184c8f3dd456f4832bd43b3fba1a205f216 /clang/lib/CodeGen/CodeGenModule.cpp
parent95f003003da878f45a7820972ad62338a30c3a21 (diff)
downloadbcm5719-llvm-6e4d774b02ae424fcc3ba4a6d35be6348c851f46.tar.gz
bcm5719-llvm-6e4d774b02ae424fcc3ba4a6d35be6348c851f46.zip
CodeGenModule.cpp: [PR33810][Modules] Avoid reusing FoundStr to try to fix crash.
MangledDeclNames might grow up and be reallocated when it were reused by reentering CodeGenModule::getMangledName(). llvm-svn: 309501
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 63d5ff3bee2..310b19c2092 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -712,9 +712,9 @@ StringRef CodeGenModule::getMangledName(GlobalDecl GD) {
}
}
- StringRef &FoundStr = MangledDeclNames[CanonicalGD];
- if (!FoundStr.empty())
- return FoundStr;
+ auto FoundName = MangledDeclNames.find(CanonicalGD);
+ if (FoundName != MangledDeclNames.end())
+ return FoundName->second;
const auto *ND = cast<NamedDecl>(GD.getDecl());
SmallString<256> Buffer;
@@ -745,9 +745,9 @@ StringRef CodeGenModule::getMangledName(GlobalDecl GD) {
// Keep the first result in the case of a mangling collision.
auto Result = Manglings.insert(std::make_pair(Str, GD));
- assert(&FoundStr == &MangledDeclNames[CanonicalGD] && "FoundStr is invalidated!");
- assert(FoundStr.empty() && "FoundStr is not empty!");
- return FoundStr = Result.first->first();
+ assert(MangledDeclNames.find(CanonicalGD) == MangledDeclNames.end() &&
+ "CanonicalGD is already mangled.");
+ return MangledDeclNames[CanonicalGD] = Result.first->first();
}
StringRef CodeGenModule::getBlockMangledName(GlobalDecl GD,
OpenPOWER on IntegriCloud