r185727 - Use llvm::sys::fs::createUniqueFile.

Rafael Espindola rafael.espindola at gmail.com
Fri Jul 5 14:13:58 PDT 2013


Author: rafael
Date: Fri Jul  5 16:13:58 2013
New Revision: 185727

URL: http://llvm.org/viewvc/llvm-project?rev=185727&view=rev
Log:
Use llvm::sys::fs::createUniqueFile.

Include a test that clang now produces output files with permissions matching
the umask.

Added:
    cfe/trunk/test/Misc/permissions.cpp
Modified:
    cfe/trunk/lib/Frontend/ASTUnit.cpp
    cfe/trunk/lib/Frontend/CompilerInstance.cpp
    cfe/trunk/lib/Rewrite/Core/Rewriter.cpp
    cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp
    cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=185727&r1=185726&r2=185727&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Fri Jul  5 16:13:58 2013
@@ -2521,8 +2521,7 @@ bool ASTUnit::Save(StringRef File) {
   TempPath = File;
   TempPath += "-%%%%%%%%";
   int fd;
-  if (llvm::sys::fs::unique_file(TempPath.str(), fd, TempPath,
-                                 /*makeAbsolute=*/false))
+  if (llvm::sys::fs::createUniqueFile(TempPath.str(), fd, TempPath))
     return true;
 
   // FIXME: Can we somehow regenerate the stat cache here, or do we need to 

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=185727&r1=185726&r2=185727&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Fri Jul  5 16:13:58 2013
@@ -544,16 +544,15 @@ CompilerInstance::createOutputFile(Strin
     TempPath = OutFile;
     TempPath += "-%%%%%%%%";
     int fd;
-    llvm::error_code EC = llvm::sys::fs::unique_file(
-        TempPath.str(), fd, TempPath, /*makeAbsolute=*/ false, 0664);
+    llvm::error_code EC =
+        llvm::sys::fs::createUniqueFile(TempPath.str(), fd, TempPath);
 
     if (CreateMissingDirectories &&
         EC == llvm::errc::no_such_file_or_directory) {
       StringRef Parent = llvm::sys::path::parent_path(OutputPath);
       EC = llvm::sys::fs::create_directories(Parent);
       if (!EC) {
-        EC = llvm::sys::fs::unique_file(TempPath.str(), fd, TempPath,
-                                        /*makeAbsolute=*/ false, 0664);
+        EC = llvm::sys::fs::createUniqueFile(TempPath.str(), fd, TempPath);
       }
     }
 

Modified: cfe/trunk/lib/Rewrite/Core/Rewriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/Core/Rewriter.cpp?rev=185727&r1=185726&r2=185727&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/Core/Rewriter.cpp (original)
+++ cfe/trunk/lib/Rewrite/Core/Rewriter.cpp Fri Jul  5 16:13:58 2013
@@ -433,8 +433,7 @@ public:
     TempFilename = Filename;
     TempFilename += "-%%%%%%%%";
     int FD;
-    if (llvm::sys::fs::unique_file(TempFilename.str(), FD, TempFilename,
-                                    /*makeAbsolute=*/true, 0664)) {
+    if (llvm::sys::fs::createUniqueFile(TempFilename.str(), FD, TempFilename)) {
       AllWritten = false;
       Diagnostics.Report(clang::diag::err_unable_to_make_temp)
         << TempFilename;

Modified: cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp?rev=185727&r1=185726&r2=185727&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp (original)
+++ cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp Fri Jul  5 16:13:58 2013
@@ -790,7 +790,8 @@ GlobalModuleIndex::writeIndex(FileManage
   // Write the global index file to a temporary file.
   llvm::SmallString<128> IndexTmpPath;
   int TmpFD;
-  if (llvm::sys::fs::unique_file(IndexPath + "-%%%%%%%%", TmpFD, IndexTmpPath))
+  if (llvm::sys::fs::createUniqueFile(IndexPath + "-%%%%%%%%", TmpFD,
+                                      IndexTmpPath))
     return EC_IOError;
 
   // Open the temporary global index file for output.

Modified: cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp?rev=185727&r1=185726&r2=185727&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp Fri Jul  5 16:13:58 2013
@@ -247,9 +247,8 @@ void HTMLDiagnostics::ReportDiag(const P
   SmallString<128> Model, ResultPath;
   llvm::sys::path::append(Model, Directory, "report-%%%%%%.html");
 
-  if (llvm::error_code EC = llvm::sys::fs::unique_file(
-          Model.str(), FD, ResultPath, false,
-          llvm::sys::fs::all_read | llvm::sys::fs::all_write)) {
+  if (llvm::error_code EC =
+          llvm::sys::fs::createUniqueFile(Model.str(), FD, ResultPath)) {
     llvm::errs() << "warning: could not create file in '" << Directory
                  << "': " << EC.message() << '\n';
     return;

Added: cfe/trunk/test/Misc/permissions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/permissions.cpp?rev=185727&view=auto
==============================================================================
--- cfe/trunk/test/Misc/permissions.cpp (added)
+++ cfe/trunk/test/Misc/permissions.cpp Fri Jul  5 16:13:58 2013
@@ -0,0 +1,11 @@
+// REQUIRES: shell
+
+// RUN: umask 000
+// RUN: %clang_cc1 -emit-llvm-bc %s -o %t
+// RUN: ls -l %t | FileCheck --check-prefix=CHECK000 %s
+// CHECK000: rw-rw-rw-
+
+// RUN: umask 002
+// RUN: %clang_cc1 -emit-llvm-bc %s -o %t
+// RUN: ls -l %t | FileCheck --check-prefix=CHECK002 %s
+// CHECK002: rw-rw-r--





More information about the cfe-commits mailing list