[llvm-commits] [llvm] r146378 - in /llvm/trunk: include/llvm/Support/FileSystem.h lib/Support/Unix/PathV2.inc lib/Support/Windows/PathV2.inc lib/Support/Windows/Windows.h unittests/Support/Path.cpp

Chad Rosier mcrosier at apple.com
Mon Dec 12 09:58:31 PST 2011


Author: mcrosier
Date: Mon Dec 12 11:58:31 2011
New Revision: 146378

URL: http://llvm.org/viewvc/llvm-project?rev=146378&view=rev
Log:
Revert r146363 to allow buildbots to make forward progress.

Original commit message:
Support/FileSystem: Implement canonicalize.

Modified:
    llvm/trunk/include/llvm/Support/FileSystem.h
    llvm/trunk/lib/Support/Unix/PathV2.inc
    llvm/trunk/lib/Support/Windows/PathV2.inc
    llvm/trunk/lib/Support/Windows/Windows.h
    llvm/trunk/unittests/Support/Path.cpp

Modified: llvm/trunk/include/llvm/Support/FileSystem.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/FileSystem.h?rev=146378&r1=146377&r2=146378&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/FileSystem.h (original)
+++ llvm/trunk/include/llvm/Support/FileSystem.h Mon Dec 12 11:58:31 2011
@@ -389,12 +389,8 @@
 
 /// @brief Canonicalize path.
 ///
-/// Sets result to the file system's idea of what path is. Path must be
-/// absolute. The result has the same case as the file system.
-///
-/// Example: Give a file system with "C:\a\b\c\file.txt".
-///
-/// C:\A\b\C\fIlE.TxT => C:\a\b\c\file.txt
+/// Sets result to the file system's idea of what path is. The result is always
+/// absolute and has the same capitalization as the file system.
 ///
 /// @param path Input path.
 /// @param result Set to the canonicalized version of \a path.

Modified: llvm/trunk/lib/Support/Unix/PathV2.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/PathV2.inc?rev=146378&r1=146377&r2=146378&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Unix/PathV2.inc (original)
+++ llvm/trunk/lib/Support/Unix/PathV2.inc Mon Dec 12 11:58:31 2011
@@ -431,13 +431,6 @@
   return success;
 }
 
-error_code canonicalize(const Twine &path, SmallVectorImpl<char> &result) {
-  // Paths are already canonicalized on posix systems.
-  assert(path::is_absolute(path) && "path must be absolute!");
-  path.toVector(result);
-  return success;
-}
-
 error_code detail::directory_iterator_construct(detail::DirIterState &it,
                                                 StringRef path){
   SmallString<128> path_null(path);

Modified: llvm/trunk/lib/Support/Windows/PathV2.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/PathV2.inc?rev=146378&r1=146377&r2=146378&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Windows/PathV2.inc (original)
+++ llvm/trunk/lib/Support/Windows/PathV2.inc Mon Dec 12 11:58:31 2011
@@ -614,44 +614,6 @@
   return success;
 }
 
-error_code canonicalize(const Twine &path, SmallVectorImpl<char> &result) {
-  assert(path::is_absolute(path) && "path must be absolute!");
-  SmallString<128> path_storage;
-  StringRef p = path.toStringRef(path_storage);
-  SmallVector<wchar_t, 128> path_utf16;
-  result.set_size(0);
-
-  // Convert path to UTF-16.
-  if (error_code ec = UTF8ToUTF16(p, path_utf16))
-    return ec;
-
-  DWORD size = ::GetShortPathNameW(c_str(path_utf16), NULL, 0);
-  SmallVector<wchar_t, 128> short_path;
-  short_path.reserve(size + 1);
-  size = ::GetShortPathNameW( c_str(path_utf16)
-                            , short_path.data()
-                            , short_path.capacity());
-  if (!size)
-    return windows_error(::GetLastError());
-
-  short_path.set_size(size);
-
-  size = ::GetLongPathNameW(c_str(short_path), NULL, 0);
-  path_utf16.reserve(size + 1);
-  size = ::GetLongPathNameW( c_str(short_path)
-                           , path_utf16.data()
-                           , path_utf16.capacity());
-  if (!size)
-    return windows_error(::GetLastError());
-
-  path_utf16.set_size(size);
-
-  if (error_code ec = UTF16ToUTF8(path_utf16.data(), path_utf16.size(), result))
-    return ec;
-
-  return success;
-}
-
 error_code get_magic(const Twine &path, uint32_t len,
                      SmallVectorImpl<char> &result) {
   SmallString<128> path_storage;

Modified: llvm/trunk/lib/Support/Windows/Windows.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Windows.h?rev=146378&r1=146377&r2=146378&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Windows/Windows.h (original)
+++ llvm/trunk/lib/Support/Windows/Windows.h Mon Dec 12 11:58:31 2011
@@ -128,24 +128,6 @@
   }
 };
 
-struct FileMappingHandleTraits : CommonHandleTraits {
-  static handle_type GetInvalid() {
-    return 0;
-  }
-};
-
-struct MappedViewOfFileHandleTraits : CommonHandleTraits {
-  typedef LPVOID handle_type;
-
-  static handle_type GetInvalid() {
-    return 0;
-  }
-
-  static void Close(handle_type h) {
-    ::UnmapViewOfFile(h);
-  }
-};
-
 struct FileHandleTraits : CommonHandleTraits {};
 
 typedef ScopedHandle<CommonHandleTraits> ScopedCommonHandle;
@@ -153,8 +135,6 @@
 typedef ScopedHandle<CryptContextTraits> ScopedCryptContext;
 typedef ScopedHandle<FindHandleTraits>   ScopedFindHandle;
 typedef ScopedHandle<JobHandleTraits>    ScopedJobHandle;
-typedef ScopedHandle<FileMappingHandleTraits> ScopedFileMappingHandle;
-typedef ScopedHandle<MappedViewOfFileHandleTraits> ScopedMappedViewOfFileHandle;
 
 namespace llvm {
 template <class T>

Modified: llvm/trunk/unittests/Support/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/Path.cpp?rev=146378&r1=146377&r2=146378&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/Path.cpp (original)
+++ llvm/trunk/unittests/Support/Path.cpp Mon Dec 12 11:58:31 2011
@@ -312,32 +312,4 @@
   }
 }
 
-TEST_F(FileSystemTest, Canonicalize) {
-  SmallString<128> file_pathname(TestDirectory);
-  path::append(file_pathname, "canonicalize", "a0", "aa1");
-
-  bool existed;
-  ASSERT_NO_ERROR(fs::create_directories(Twine(TestDirectory)
-                  + "/canonicalize/a0/aa1", existed));
-
-  {
-    path::append(file_pathname, "file.txt");
-    std::string ErrMsg;
-    raw_fd_ostream file(file_pathname.c_str(), ErrMsg);
-    file << "hello\n";
-  }
-
-  SmallString<0> res;
-  ASSERT_NO_ERROR(fs::canonicalize(Twine(TestDirectory)
-                                   + "/cAnOnIcAlIzE/A0/aA1/fIlE.TxT", res));
-  // Only check if we actually found the file. As we won't find it on case
-  // sensitive file systems.
-  if (fs::exists(res.str())) {
-    ASSERT_TRUE(res.str().find("canonicalize") != StringRef::npos);
-    ASSERT_TRUE(res.str().find("a0") != StringRef::npos);
-    ASSERT_TRUE(res.str().find("aa1") != StringRef::npos);
-    ASSERT_TRUE(res.str().find("file.txt") != StringRef::npos);
-  }
-}
-
 } // anonymous namespace





More information about the llvm-commits mailing list