From: Daniel Jasper Date: Thu, 29 Oct 2015 12:49:37 +0000 (+0000) Subject: Fix use-after-free. Thanks ASAN for giving me a detailed report :-). X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=4da93a6599abc2380213192bef506840e863c877 Fix use-after-free. Thanks ASAN for giving me a detailed report :-). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251623 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/IPO/SampleProfile.cpp b/lib/Transforms/IPO/SampleProfile.cpp index 47250cccc4d..51e95a5887a 100644 --- a/lib/Transforms/IPO/SampleProfile.cpp +++ b/lib/Transforms/IPO/SampleProfile.cpp @@ -380,9 +380,9 @@ bool SampleProfileLoader::computeBlockWeights(Function &F) { if (SampleProfileCoverage) { unsigned Coverage = CoverageTracker.computeCoverage(Samples); if (Coverage < SampleProfileCoverage) { - const char *Filename = getDISubprogram(&F)->getFilename().str().c_str(); + StringRef Filename = getDISubprogram(&F)->getFilename(); F.getContext().diagnose(DiagnosticInfoSampleProfile( - Filename, getFunctionLoc(F), + Filename.str().c_str(), getFunctionLoc(F), Twine(CoverageTracker.getNumUsedSamples(Samples)) + " of " + Twine(Samples->getBodySamples().size()) + " available profile records (" + Twine(Coverage) +