[llvm] r274861 - Make a std::string copy of StringRef Name so that it remains valid when the original Name is overridden.
Eric Liu via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 8 09:09:48 PDT 2016
Author: ioeric
Date: Fri Jul 8 11:09:48 2016
New Revision: 274861
URL: http://llvm.org/viewvc/llvm-project?rev=274861&view=rev
Log:
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
Modified:
llvm/trunk/lib/IR/AutoUpgrade.cpp
Modified: llvm/trunk/lib/IR/AutoUpgrade.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AutoUpgrade.cpp?rev=274861&r1=274860&r2=274861&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AutoUpgrade.cpp (original)
+++ llvm/trunk/lib/IR/AutoUpgrade.cpp Fri Jul 8 11:09:48 2016
@@ -67,7 +67,10 @@ static bool UpgradeIntrinsicFunction1(Fu
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."
More information about the llvm-commits
mailing list