diff options
author | Eric Liu <ioeric@google.com> | 2016-07-08 16:09:48 +0000 |
---|---|---|
committer | Eric Liu <ioeric@google.com> | 2016-07-08 16:09:48 +0000 |
commit | 6ee4e81a326f49212b394d6834e634644b4ed104 (patch) | |
tree | 06eb395b041d056d613827c64a029f652d773899 /llvm/lib/IR/AutoUpgrade.cpp | |
parent | e1acad9b618e4010a94f8ee229dd31611445805e (diff) | |
download | bcm5719-llvm-6ee4e81a326f49212b394d6834e634644b4ed104.tar.gz bcm5719-llvm-6ee4e81a326f49212b394d6834e634644b4ed104.zip |
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
Diffstat (limited to 'llvm/lib/IR/AutoUpgrade.cpp')
-rw-r--r-- | llvm/lib/IR/AutoUpgrade.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp index 7e52bdb36a9..af550eb7146 100644 --- a/llvm/lib/IR/AutoUpgrade.cpp +++ b/llvm/lib/IR/AutoUpgrade.cpp @@ -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." |