From: Cameron Esfahani Date: Thu, 1 Oct 2015 01:24:59 +0000 (+0000) Subject: createUniqueFile() is documented to create the file in the temporary directory unless... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=619bc166a16154b1b97a8605d2eb11dff8070f1e;p=clang createUniqueFile() is documented to create the file in the temporary directory unless it's supplied an absolute path. Make sure the output filepath supplied to createUniqueFile() in HTMLDiagnostics::ReportDiag() is absolute. Summary: Make sure the output filepath supplied to createUniqueFile() in HTMLDiagnostics::ReportDiag() is absolute. Reviewers: rsmith, akyrtzi Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D12774 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248977 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp b/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp index cfcf7c6a99..697aff9a67 100644 --- a/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp +++ b/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp @@ -281,7 +281,12 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D, if (!AnalyzerOpts.shouldWriteStableReportFilename()) { llvm::sys::path::append(Model, Directory, "report-%%%%%%.html"); - + if (std::error_code EC = + llvm::sys::fs::make_absolute(Model)) { + llvm::errs() << "warning: could not make '" << Model + << "' absolute: " << EC.message() << '\n'; + return; + } if (std::error_code EC = llvm::sys::fs::createUniqueFile(Model, FD, ResultPath)) { llvm::errs() << "warning: could not create file in '" << Directory