[llvm-commits] [llvm] r123151 - in /llvm/trunk: include/llvm/Support/PathV1.h lib/Archive/Archive.cpp lib/Archive/ArchiveWriter.cpp lib/CompilerDriver/Main.cpp lib/Support/Path.cpp lib/Support/Unix/Path.inc lib/Support/Unix/Program.inc lib/Support/Windows/Path.inc tools/llvm-ar/llvm-ar.cpp tools/llvm-ranlib/llvm-ranlib.cpp
Michael J. Spencer
bigcheesegs at gmail.com
Sun Jan 9 18:34:23 PST 2011
Author: mspencer
Date: Sun Jan 9 20:34:23 2011
New Revision: 123151
URL: http://llvm.org/viewvc/llvm-project?rev=123151&view=rev
Log:
Support/Path: Deprecate PathV1::exists and replace all uses with PathV2::fs::exists.
Modified:
llvm/trunk/include/llvm/Support/PathV1.h
llvm/trunk/lib/Archive/Archive.cpp
llvm/trunk/lib/Archive/ArchiveWriter.cpp
llvm/trunk/lib/CompilerDriver/Main.cpp
llvm/trunk/lib/Support/Path.cpp
llvm/trunk/lib/Support/Unix/Path.inc
llvm/trunk/lib/Support/Unix/Program.inc
llvm/trunk/lib/Support/Windows/Path.inc
llvm/trunk/tools/llvm-ar/llvm-ar.cpp
llvm/trunk/tools/llvm-ranlib/llvm-ranlib.cpp
Modified: llvm/trunk/include/llvm/Support/PathV1.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/PathV1.h?rev=123151&r1=123150&r2=123151&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/PathV1.h (original)
+++ llvm/trunk/include/llvm/Support/PathV1.h Sun Jan 9 20:34:23 2011
@@ -380,7 +380,8 @@
/// directory.
/// @brief Determines if the path is a file or directory in
/// the file system.
- bool exists() const;
+ LLVM_ATTRIBUTE_DEPRECATED(bool exists() const,
+ LLVM_PATH_DEPRECATED_MSG(fs::exists));
/// This function determines if the path name references an
/// existing directory.
Modified: llvm/trunk/lib/Archive/Archive.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Archive/Archive.cpp?rev=123151&r1=123150&r2=123151&view=diff
==============================================================================
--- llvm/trunk/lib/Archive/Archive.cpp (original)
+++ llvm/trunk/lib/Archive/Archive.cpp Sun Jan 9 20:34:23 2011
@@ -15,6 +15,7 @@
#include "ArchiveInternals.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/Module.h"
+#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/system_error.h"
@@ -66,8 +67,9 @@
// different file, presumably as an update to the member. It also makes sure
// the flags are reset correctly.
bool ArchiveMember::replaceWith(const sys::Path& newFile, std::string* ErrMsg) {
- if (!newFile.exists()) {
- if (ErrMsg)
+ bool Exists;
+ if (sys::fs::exists(newFile.str(), Exists) || !Exists) {
+ if (ErrMsg)
*ErrMsg = "Can not replace an archive member with a non-existent file";
return true;
}
Modified: llvm/trunk/lib/Archive/ArchiveWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Archive/ArchiveWriter.cpp?rev=123151&r1=123150&r2=123151&view=diff
==============================================================================
--- llvm/trunk/lib/Archive/ArchiveWriter.cpp (original)
+++ llvm/trunk/lib/Archive/ArchiveWriter.cpp Sun Jan 9 20:34:23 2011
@@ -15,6 +15,7 @@
#include "llvm/Module.h"
#include "llvm/ADT/OwningPtr.h"
#include "llvm/Bitcode/ReaderWriter.h"
+#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/Signals.h"
@@ -156,7 +157,8 @@
bool
Archive::addFileBefore(const sys::Path& filePath, iterator where,
std::string* ErrMsg) {
- if (!filePath.exists()) {
+ bool Exists;
+ if (sys::fs::exists(filePath.str(), Exists) || !Exists) {
if (ErrMsg)
*ErrMsg = "Can not add a non-existent file to archive";
return true;
Modified: llvm/trunk/lib/CompilerDriver/Main.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CompilerDriver/Main.cpp?rev=123151&r1=123150&r2=123151&view=diff
==============================================================================
--- llvm/trunk/lib/CompilerDriver/Main.cpp (original)
+++ llvm/trunk/lib/CompilerDriver/Main.cpp Sun Jan 9 20:34:23 2011
@@ -16,6 +16,7 @@
#include "llvm/CompilerDriver/CompilationGraph.h"
#include "llvm/CompilerDriver/Error.h"
+#include "llvm/Support/FileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Path.h"
@@ -50,7 +51,8 @@
return 0;
}
- if (!tempDir.exists()) {
+ bool Exists;
+ if (llvm::sys::fs::exists(tempDir.str(), Exists) || !Exists) {
std::string ErrMsg;
if (tempDir.createDirectoryOnDisk(true, &ErrMsg)) {
PrintError(ErrMsg);
Modified: llvm/trunk/lib/Support/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Path.cpp?rev=123151&r1=123150&r2=123151&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Path.cpp (original)
+++ llvm/trunk/lib/Support/Path.cpp Sun Jan 9 20:34:23 2011
@@ -13,6 +13,7 @@
#include "llvm/Support/Path.h"
#include "llvm/Config/config.h"
+#include "llvm/Support/FileSystem.h"
#include <cassert>
#include <cstring>
#include <ostream>
Modified: llvm/trunk/lib/Support/Unix/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Path.inc?rev=123151&r1=123150&r2=123151&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Unix/Path.inc (original)
+++ llvm/trunk/lib/Support/Unix/Path.inc Sun Jan 9 20:34:23 2011
@@ -811,7 +811,8 @@
bool
Path::makeUnique(bool reuse_current, std::string* ErrMsg) {
- if (reuse_current && !exists())
+ bool Exists;
+ if (reuse_current && (fs::exists(path, Exists) || !Exists))
return false; // File doesn't exist already, just use it!
// Append an XXXXXX pattern to the end of the file for use with mkstemp,
Modified: llvm/trunk/lib/Support/Unix/Program.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Program.inc?rev=123151&r1=123150&r2=123151&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Unix/Program.inc (original)
+++ llvm/trunk/lib/Support/Unix/Program.inc Sun Jan 9 20:34:23 2011
@@ -17,6 +17,7 @@
//===----------------------------------------------------------------------===//
#include <llvm/Config/config.h>
+#include "llvm/Support/FileSystem.h"
#include "Unix.h"
#if HAVE_SYS_STAT_H
#include <sys/stat.h>
@@ -355,7 +356,8 @@
// Following the POSIX convention for command-line tools (which posix_spawn
// itself apparently does not), check to see if the failure was due to some
// reason other than the file not existing, and return 126 in this case.
- if (result == 127 && path.exists())
+ bool Exists;
+ if (result == 127 && !llvm::sys::fs::exists(path.str(), Exists) && Exists)
result = 126;
#endif
if (result == 127) {
Modified: llvm/trunk/lib/Support/Windows/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Path.inc?rev=123151&r1=123150&r2=123151&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Windows/Path.inc (original)
+++ llvm/trunk/lib/Support/Windows/Path.inc Sun Jan 9 20:34:23 2011
@@ -694,7 +694,8 @@
if (fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
// If it doesn't exist, we're done.
- if (!exists())
+ bool Exists;
+ if (fs::exists(path, Exists) || !Exists)
return false;
char *pathname = reinterpret_cast<char *>(_alloca(path.length()+3));
@@ -868,7 +869,8 @@
bool
Path::makeUnique(bool reuse_current, std::string* ErrMsg) {
- if (reuse_current && !exists())
+ bool Exists;
+ if (reuse_current && (fs::exists(path, Exists) || !Exists))
return false; // File doesn't exist already, just use it!
// Reserve space for -XXXXXX at the end.
@@ -885,7 +887,7 @@
if (++FCounter > 999999)
FCounter = 0;
path = FNBuffer;
- } while (exists());
+ } while (!fs::exists(path, Exists) && Exists);
return false;
}
Modified: llvm/trunk/tools/llvm-ar/llvm-ar.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/llvm-ar.cpp?rev=123151&r1=123150&r2=123151&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/llvm-ar.cpp (original)
+++ llvm/trunk/tools/llvm-ar/llvm-ar.cpp Sun Jan 9 20:34:23 2011
@@ -16,6 +16,7 @@
#include "llvm/Module.h"
#include "llvm/Bitcode/Archive.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/Format.h"
@@ -310,7 +311,8 @@
if (!aPath.set(Members[i]))
throw std::string("File member name invalid: ") + Members[i];
if (checkExistence) {
- if (!aPath.exists())
+ bool Exists;
+ if (sys::fs::exists(aPath.str(), Exists) || !Exists)
throw std::string("File does not exist: ") + Members[i];
std::string Err;
sys::PathWithStatus PwS(aPath);
@@ -715,7 +717,8 @@
throw std::string("Archive name invalid: ") + ArchiveName;
// Create or open the archive object.
- if (!ArchivePath.exists()) {
+ bool Exists;
+ if (llvm::sys::fs::exists(ArchivePath.str(), Exists) || !Exists) {
// Produce a warning if we should and we're creating the archive
if (!Create)
errs() << argv[0] << ": creating " << ArchivePath.str() << "\n";
Modified: llvm/trunk/tools/llvm-ranlib/llvm-ranlib.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ranlib/llvm-ranlib.cpp?rev=123151&r1=123150&r2=123151&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ranlib/llvm-ranlib.cpp (original)
+++ llvm/trunk/tools/llvm-ranlib/llvm-ranlib.cpp Sun Jan 9 20:34:23 2011
@@ -15,6 +15,7 @@
#include "llvm/Module.h"
#include "llvm/Bitcode/Archive.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/Format.h"
@@ -69,7 +70,8 @@
throw std::string("Archive name invalid: ") + ArchiveName;
// Make sure it exists, we don't create empty archives
- if (!ArchivePath.exists())
+ bool Exists;
+ if (llvm::sys::fs::exists(ArchivePath.str(), Exists) || !Exists)
throw std::string("Archive file does not exist");
std::string err_msg;
More information about the llvm-commits
mailing list