llvm.org GIT mirror llvm / f760df8
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274861 91177308-0d34-0410-b5e6-96231b3b80d8 Eric Liu 4 years ago
1 changed file(s) with 4 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
6666 assert(F && "Illegal to upgrade a non-existent Function.");
6767
6868 // Quickly eliminate it, if it's not a candidate.
69 StringRef Name = F->getName();
69 // Make a copy of the name so that we don't need to worry about the life-time
70 // of StringRef.
71 std::string NameStr = F->getName().str();
72 StringRef Name = NameStr;
7073 if (Name.size() <= 8 || !Name.startswith("llvm."))
7174 return false;
7275 Name = Name.substr(5); // Strip off "llvm."