1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 19:42:54 +02:00

Make a std::string copy of StringRef Name so that it remains valid when the original Name is overridden.

Summary: lib/IR/AutoUpgrade.cpp:348 and lib/IR/AutoUpgrade.cpp:350 upset sanitizer.

Reviewers: bkramer

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D22140

llvm-svn: 274861
This commit is contained in:
Eric Liu 2016-07-08 16:09:48 +00:00
parent 3eb1e8fba4
commit 7327cd030c

View File

@ -67,7 +67,10 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
assert(F && "Illegal to upgrade a non-existent Function.");
// Quickly eliminate it, if it's not a candidate.
StringRef Name = F->getName();
// Make a copy of the name so that we don't need to worry about the life-time
// of StringRef.
std::string NameStr = F->getName().str();
StringRef Name = NameStr;
if (Name.size() <= 8 || !Name.startswith("llvm."))
return false;
Name = Name.substr(5); // Strip off "llvm."