]> granicus.if.org Git - clang/commitdiff
createUniqueFile() is documented to create the file in the temporary directory unless...
authorCameron Esfahani <dirty@apple.com>
Thu, 1 Oct 2015 01:24:59 +0000 (01:24 +0000)
committerCameron Esfahani <dirty@apple.com>
Thu, 1 Oct 2015 01:24:59 +0000 (01:24 +0000)
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

lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp

index cfcf7c6a990b462d6a4c5d8cc200318b0d174c3f..697aff9a67ad879020ceed2db6ac6018b48edd45 100644 (file)
@@ -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