<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 2, 2015 at 12:01 PM, David Blaikie via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: dblaikie<br>
Date: Mon Nov  2 14:01:13 2015<br>
New Revision: 251823<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=251823&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=251823&view=rev</a><br>
Log:<br>
StringRef-ify DiagnosticInfoSampleProfile::Filename<br>
<br>
Modified:<br>
    llvm/trunk/cmake/modules/HandleLLVMOptions.cmake<br></blockquote><div><br></div><div>Reverted the accidental cmake change in r251826</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
    llvm/trunk/include/llvm/IR/DiagnosticInfo.h<br>
    llvm/trunk/lib/IR/DiagnosticInfo.cpp<br>
    llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp<br>
<br>
Modified: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/HandleLLVMOptions.cmake?rev=251823&r1=251822&r2=251823&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/HandleLLVMOptions.cmake?rev=251823&r1=251822&r2=251823&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/cmake/modules/HandleLLVMOptions.cmake (original)<br>
+++ llvm/trunk/cmake/modules/HandleLLVMOptions.cmake Mon Nov  2 14:01:13 2015<br>
@@ -18,7 +18,7 @@ if(NOT LLVM_FORCE_USE_OLD_TOOLCHAIN)<br>
     endif()<br>
   elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")<br>
     if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1)<br>
-      message(FATAL_ERROR "Host Clang version must be at least 3.1!")<br>
+           #    message(FATAL_ERROR "Host Clang version must be at least 3.1!")<br>
     endif()<br>
<br>
     if (CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")<br>
<br>
Modified: llvm/trunk/include/llvm/IR/DiagnosticInfo.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DiagnosticInfo.h?rev=251823&r1=251822&r2=251823&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DiagnosticInfo.h?rev=251823&r1=251822&r2=251823&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/IR/DiagnosticInfo.h (original)<br>
+++ llvm/trunk/include/llvm/IR/DiagnosticInfo.h Mon Nov  2 14:01:13 2015<br>
@@ -214,19 +214,18 @@ public:<br>
 /// Diagnostic information for the sample profiler.<br>
 class DiagnosticInfoSampleProfile : public DiagnosticInfo {<br>
 public:<br>
-  DiagnosticInfoSampleProfile(const char *FileName, unsigned LineNum,<br>
+  DiagnosticInfoSampleProfile(StringRef FileName, unsigned LineNum,<br>
                               const Twine &Msg,<br>
                               DiagnosticSeverity Severity = DS_Error)<br>
       : DiagnosticInfo(DK_SampleProfile, Severity), FileName(FileName),<br>
         LineNum(LineNum), Msg(Msg) {}<br>
-  DiagnosticInfoSampleProfile(const char *FileName, const Twine &Msg,<br>
+  DiagnosticInfoSampleProfile(StringRef FileName, const Twine &Msg,<br>
                               DiagnosticSeverity Severity = DS_Error)<br>
       : DiagnosticInfo(DK_SampleProfile, Severity), FileName(FileName),<br>
         LineNum(0), Msg(Msg) {}<br>
   DiagnosticInfoSampleProfile(const Twine &Msg,<br>
                               DiagnosticSeverity Severity = DS_Error)<br>
-      : DiagnosticInfo(DK_SampleProfile, Severity), FileName(nullptr),<br>
-        LineNum(0), Msg(Msg) {}<br>
+      : DiagnosticInfo(DK_SampleProfile, Severity), LineNum(0), Msg(Msg) {}<br>
<br>
   /// \see DiagnosticInfo::print.<br>
   void print(DiagnosticPrinter &DP) const override;<br>
@@ -235,13 +234,13 @@ public:<br>
     return DI->getKind() == DK_SampleProfile;<br>
   }<br>
<br>
-  const char *getFileName() const { return FileName; }<br>
+  StringRef getFileName() const { return FileName; }<br>
   unsigned getLineNum() const { return LineNum; }<br>
   const Twine &getMsg() const { return Msg; }<br>
<br>
 private:<br>
   /// Name of the input file associated with this diagnostic.<br>
-  const char *FileName;<br>
+  StringRef FileName;<br>
<br>
   /// Line number where the diagnostic occurred. If 0, no line number will<br>
   /// be emitted in the message.<br>
<br>
Modified: llvm/trunk/lib/IR/DiagnosticInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DiagnosticInfo.cpp?rev=251823&r1=251822&r2=251823&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DiagnosticInfo.cpp?rev=251823&r1=251822&r2=251823&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/IR/DiagnosticInfo.cpp (original)<br>
+++ llvm/trunk/lib/IR/DiagnosticInfo.cpp Mon Nov  2 14:01:13 2015<br>
@@ -123,10 +123,12 @@ void DiagnosticInfoDebugMetadataVersion:<br>
 }<br>
<br>
 void DiagnosticInfoSampleProfile::print(DiagnosticPrinter &DP) const {<br>
-  if (getFileName() && getLineNum() > 0)<br>
-    DP << getFileName() << ":" << getLineNum() << ": ";<br>
-  else if (getFileName())<br>
-    DP << getFileName() << ": ";<br>
+  if (!FileName.empty()) {<br>
+    DP << getFileName();<br>
+    if (LineNum > 0)<br>
+      DP << ":" << getLineNum();<br>
+    DP << ": ";<br>
+  }<br>
   DP << getMsg();<br>
 }<br>
<br>
<br>
Modified: llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp?rev=251823&r1=251822&r2=251823&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp?rev=251823&r1=251822&r2=251823&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp Mon Nov  2 14:01:13 2015<br>
@@ -1009,9 +1009,8 @@ bool SampleProfileLoader::emitAnnotation<br>
     unsigned Total = CoverageTracker.countBodySamples(Samples);<br>
     unsigned Coverage = CoverageTracker.computeCoverage(Used, Total);<br>
     if (Coverage < SampleProfileCoverage) {<br>
-      StringRef Filename = getDISubprogram(&F)->getFilename();<br>
       F.getContext().diagnose(DiagnosticInfoSampleProfile(<br>
-          Filename.str().c_str(), getFunctionLoc(F),<br>
+          getDISubprogram(&F)->getFilename(), getFunctionLoc(F),<br>
           Twine(Used) + " of " + Twine(Total) + " available profile records (" +<br>
               Twine(Coverage) + "%) were applied",<br>
           DS_Warning));<br>
@@ -1033,7 +1032,7 @@ bool SampleProfileLoader::doInitializati<br>
   auto ReaderOrErr = SampleProfileReader::create(Filename, Ctx);<br>
   if (std::error_code EC = ReaderOrErr.getError()) {<br>
     std::string Msg = "Could not open profile: " + EC.message();<br>
-    Ctx.diagnose(DiagnosticInfoSampleProfile(Filename.data(), Msg));<br>
+    Ctx.diagnose(DiagnosticInfoSampleProfile(Filename, Msg));<br>
     return false;<br>
   }<br>
   Reader = std::move(ReaderOrErr.get());<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>