[llvm] r187378 - Include st_dev to make the result of getUniqueID actually unique.

Rafael EspĂ­ndola rafael.espindola at gmail.com
Mon Jul 29 15:01:03 PDT 2013


I updated clang in 187379.

On 29 July 2013 17:47, David Dean <david_dean at apple.com> wrote:
> I'm seeing a compilation failure after this commit:
>
> ..\..\..\..\..\..\src\tools\clang\lib\Basic\SourceManager.cpp(1588): error C2664: 'llvm::sys::fs::getUniqueID' : cannot convert parameter 2 from 'uint64_t' to 'llvm::sys::fs::UniqueID &' [C:\public\zorg\buildbot\smooshlab\slave-0.8\...\clang-build\189702\tools\clang\lib\Basic\clangBasic.vcxproj]
>
>
> On 29 Jul 2013, at 2:26 PM, Rafael Espindola <rafael.espindola at gmail.com> wrote:
>
>> Author: rafael
>> Date: Mon Jul 29 16:26:49 2013
>> New Revision: 187378
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=187378&view=rev
>> Log:
>> Include st_dev to make the result of getUniqueID actually unique.
>>
>> This will let us use getUniqueID instead of st_dev directly on clang.
>>
>> Modified:
>>    llvm/trunk/include/llvm/Support/FileSystem.h
>>    llvm/trunk/lib/Support/Path.cpp
>>    llvm/trunk/lib/Support/Unix/Path.inc
>>    llvm/trunk/lib/Support/Windows/Path.inc
>>    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=187378&r1=187377&r2=187378&view=diff
>> ==============================================================================
>> --- llvm/trunk/include/llvm/Support/FileSystem.h (original)
>> +++ llvm/trunk/include/llvm/Support/FileSystem.h Mon Jul 29 16:26:49 2013
>> @@ -125,8 +125,19 @@ inline perms operator~(perms x) {
>>   return static_cast<perms>(~static_cast<unsigned short>(x));
>> }
>>
>> +class UniqueID {
>> +  uint64_t A;
>> +  uint64_t B;
>> +
>> +public:
>> +  UniqueID() {}
>> +  UniqueID(uint64_t A, uint64_t B) : A(A), B(B) {}
>> +  bool operator==(const UniqueID &Other) const {
>> +    return A == Other.A && B == Other.B;
>> +  }
>> +  bool operator!=(const UniqueID &Other) const { return !(*this == Other); }
>> +};
>>
>> -
>> /// file_status - Represents the result of a call to stat and friends. It has
>> ///               a platform specific member to store the result.
>> class file_status
>> @@ -148,7 +159,6 @@ class file_status
>>   uint32_t FileIndexLow;
>>   #endif
>>   friend bool equivalent(file_status A, file_status B);
>> -  friend error_code getUniqueID(const Twine Path, uint64_t &Result);
>>   file_type Type;
>>   perms Perms;
>> public:
>> @@ -176,6 +186,7 @@ public:
>>   file_type type() const { return Type; }
>>   perms permissions() const { return Perms; }
>>   TimeValue getLastModificationTime() const;
>> +  UniqueID getUniqueID();
>>
>>   #if defined(LLVM_ON_UNIX)
>>   uint32_t getUser() const { return fs_st_uid; }
>> @@ -664,7 +675,7 @@ file_magic identify_magic(StringRef magi
>> ///          platform specific error_code.
>> error_code identify_magic(const Twine &path, file_magic &result);
>>
>> -error_code getUniqueID(const Twine Path, uint64_t &Result);
>> +error_code getUniqueID(const Twine Path, UniqueID &Result);
>>
>> /// This class represents a memory mapped file. It is based on
>> /// boost::iostreams::mapped_file.
>>
>> Modified: llvm/trunk/lib/Support/Path.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Path.cpp?rev=187378&r1=187377&r2=187378&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Support/Path.cpp (original)
>> +++ llvm/trunk/lib/Support/Path.cpp Mon Jul 29 16:26:49 2013
>> @@ -638,6 +638,15 @@ bool is_relative(const Twine &path) {
>>
>> namespace fs {
>>
>> +error_code getUniqueID(const Twine Path, UniqueID &Result) {
>> +  file_status Status;
>> +  error_code EC = status(Path, Status);
>> +  if (EC)
>> +    return EC;
>> +  Result = Status.getUniqueID();
>> +  return error_code::success();
>> +}
>> +
>> error_code createUniqueFile(const Twine &Model, int &ResultFd,
>>                             SmallVectorImpl<char> &ResultPath, unsigned Mode) {
>>   return createUniqueEntity(Model, ResultFd, ResultPath, false, Mode, FS_File);
>>
>> Modified: llvm/trunk/lib/Support/Unix/Path.inc
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Path.inc?rev=187378&r1=187377&r2=187378&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Support/Unix/Path.inc (original)
>> +++ llvm/trunk/lib/Support/Unix/Path.inc Mon Jul 29 16:26:49 2013
>> @@ -293,6 +293,10 @@ TimeValue file_status::getLastModificati
>>   return Ret;
>> }
>>
>> +UniqueID file_status::getUniqueID() {
>> +  return UniqueID(fs_st_dev, fs_st_ino);
>> +}
>> +
>> error_code current_path(SmallVectorImpl<char> &result) {
>> #ifdef MAXPATHLEN
>>   result.reserve(MAXPATHLEN);
>> @@ -457,18 +461,6 @@ error_code equivalent(const Twine &A, co
>>   return error_code::success();
>> }
>>
>> -error_code getUniqueID(const Twine Path, uint64_t &Result) {
>> -  SmallString<128> Storage;
>> -  StringRef P = Path.toNullTerminatedStringRef(Storage);
>> -
>> -  struct stat Status;
>> -  if (::stat(P.begin(), &Status) != 0)
>> -    return error_code(errno, system_category());
>> -
>> -  Result = Status.st_ino;
>> -  return error_code::success();
>> -}
>> -
>> static error_code fillStatus(int StatRet, const struct stat &Status,
>>                              file_status &Result) {
>>   if (StatRet != 0) {
>>
>> Modified: llvm/trunk/lib/Support/Windows/Path.inc
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Path.inc?rev=187378&r1=187377&r2=187378&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Support/Windows/Path.inc (original)
>> +++ llvm/trunk/lib/Support/Windows/Path.inc Mon Jul 29 16:26:49 2013
>> @@ -269,6 +269,14 @@ std::string getMainExecutable(const char
>>   return ret != MAX_PATH ? pathname : "";
>> }
>>
>> +UniqueID file_status::getUniqueID() {
>> +  // The file is uniquely identified by the volume serial number along
>> +  // with the 64-bit file identifier.
>> +  uint64_t FileID = (static_cast<uint64_t>(FileIndexHigh) << 32ULL) |
>> +                    static_cast<uint64_t>(FileIndexLow);
>> +
>> +  return UniqueID(VolumeSerialNumber, FileID);
>> +}
>>
>> TimeValue file_status::getLastModificationTime() const {
>>   ULARGE_INTEGER UI;
>> @@ -533,25 +541,6 @@ error_code equivalent(const Twine &A, co
>>   return error_code::success();
>> }
>>
>> -error_code getUniqueID(const Twine Path, uint64_t &Result) {
>> -  file_status Status;
>> -  if (error_code E = status(Path, Status))
>> -    return E;
>> -
>> -  // The file is uniquely identified by the volume serial number along
>> -  // with the 64-bit file identifier.
>> -  Result = (static_cast<uint64_t>(Status.FileIndexHigh) << 32ULL) |
>> -           static_cast<uint64_t>(Status.FileIndexLow);
>> -
>> -  // Because the serial number is 32-bits, but we've already used up all 64
>> -  // bits for the file index, XOR the serial number into the high 32 bits of
>> -  // the resulting value.  We could potentially get collisons from this, but
>> -  // the likelihood is low.
>> -  Result ^= (static_cast<uint64_t>(Status.VolumeSerialNumber) << 32ULL);
>> -
>> -  return error_code::success();
>> -}
>> -
>> static bool isReservedName(StringRef path) {
>>   // This list of reserved names comes from MSDN, at:
>>   // http://msdn.microsoft.com/en-us/library/aa365247%28v=vs.85%29.aspx
>>
>> Modified: llvm/trunk/unittests/Support/Path.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/Path.cpp?rev=187378&r1=187377&r2=187378&view=diff
>> ==============================================================================
>> --- llvm/trunk/unittests/Support/Path.cpp (original)
>> +++ llvm/trunk/unittests/Support/Path.cpp Mon Jul 29 16:26:49 2013
>> @@ -169,7 +169,7 @@ TEST_F(FileSystemTest, Unique) {
>>       fs::createTemporaryFile("prefix", "temp", FileDescriptor, TempPath));
>>
>>   // The same file should return an identical unique id.
>> -  uint64_t F1, F2;
>> +  fs::UniqueID F1, F2;
>>   ASSERT_NO_ERROR(fs::getUniqueID(Twine(TempPath), F1));
>>   ASSERT_NO_ERROR(fs::getUniqueID(Twine(TempPath), F2));
>>   ASSERT_EQ(F1, F2);
>> @@ -180,7 +180,7 @@ TEST_F(FileSystemTest, Unique) {
>>   ASSERT_NO_ERROR(
>>       fs::createTemporaryFile("prefix", "temp", FileDescriptor2, TempPath2));
>>
>> -  uint64_t D;
>> +  fs::UniqueID D;
>>   ASSERT_NO_ERROR(fs::getUniqueID(Twine(TempPath2), D));
>>   ASSERT_NE(D, F1);
>>   ::close(FileDescriptor2);
>> @@ -190,7 +190,7 @@ TEST_F(FileSystemTest, Unique) {
>>   // Two paths representing the same file on disk should still provide the
>>   // same unique id.  We can test this by making a hard link.
>>   ASSERT_NO_ERROR(fs::create_hard_link(Twine(TempPath), Twine(TempPath2)));
>> -  uint64_t D2;
>> +  fs::UniqueID D2;
>>   ASSERT_NO_ERROR(fs::getUniqueID(Twine(TempPath2), D2));
>>   ASSERT_EQ(D2, F1);
>>
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
> -David
>
>




More information about the llvm-commits mailing list