From: Rafael Espindola Date: Mon, 29 Jul 2013 18:43:40 +0000 (+0000) Subject: Convert a use of status with llvm::sys::fs::getUniqueID. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3dadc85330d8f548b49f97d7e2fa62c73f7463dd;p=clang Convert a use of status with llvm::sys::fs::getUniqueID. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187367 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp index 2e3fb7db41..aba3e150f2 100644 --- a/lib/Basic/SourceManager.cpp +++ b/lib/Basic/SourceManager.cpp @@ -1580,15 +1580,15 @@ unsigned SourceManager::getFileIDSize(FileID FID) const { /// /// This routine involves a system call, and therefore should only be used /// in non-performance-critical code. -static Optional getActualFileInode(const FileEntry *File) { +static Optional getActualFileUID(const FileEntry *File) { if (!File) return None; - - struct stat StatBuf; - if (::stat(File->getName(), &StatBuf)) + + uint64_t ID; + if (llvm::sys::fs::getUniqueID(File->getName(), ID)) return None; - - return StatBuf.st_ino; + + return ID; } /// \brief Get the source location for the given file:line:col triplet. @@ -1617,7 +1617,7 @@ FileID SourceManager::translateFile(const FileEntry *SourceFile) const { // First, check the main file ID, since it is common to look for a // location in the main file. - Optional SourceFileInode; + Optional SourceFileUID; Optional SourceFileName; if (!MainFileID.isInvalid()) { bool Invalid = false; @@ -1638,10 +1638,10 @@ FileID SourceManager::translateFile(const FileEntry *SourceFile) const { const FileEntry *MainFile = MainContentCache->OrigEntry; SourceFileName = llvm::sys::path::filename(SourceFile->getName()); if (*SourceFileName == llvm::sys::path::filename(MainFile->getName())) { - SourceFileInode = getActualFileInode(SourceFile); - if (SourceFileInode) { - if (Optional MainFileInode = getActualFileInode(MainFile)) { - if (*SourceFileInode == *MainFileInode) { + SourceFileUID = getActualFileUID(SourceFile); + if (SourceFileUID) { + if (Optional MainFileUID = getActualFileUID(MainFile)) { + if (*SourceFileUID == *MainFileUID) { FirstFID = MainFileID; SourceFile = MainFile; } @@ -1684,12 +1684,11 @@ FileID SourceManager::translateFile(const FileEntry *SourceFile) const { // If we haven't found what we want yet, try again, but this time stat() // each of the files in case the files have changed since we originally - // parsed the file. + // parsed the file. if (FirstFID.isInvalid() && - (SourceFileName || + (SourceFileName || (SourceFileName = llvm::sys::path::filename(SourceFile->getName()))) && - (SourceFileInode || - (SourceFileInode = getActualFileInode(SourceFile)))) { + (SourceFileUID || (SourceFileUID = getActualFileUID(SourceFile)))) { bool Invalid = false; for (unsigned I = 0, N = local_sloc_entry_size(); I != N; ++I) { FileID IFileID; @@ -1704,8 +1703,8 @@ FileID SourceManager::translateFile(const FileEntry *SourceFile) const { const FileEntry *Entry =FileContentCache? FileContentCache->OrigEntry : 0; if (Entry && *SourceFileName == llvm::sys::path::filename(Entry->getName())) { - if (Optional EntryInode = getActualFileInode(Entry)) { - if (*SourceFileInode == *EntryInode) { + if (Optional EntryUID = getActualFileUID(Entry)) { + if (*SourceFileUID == *EntryUID) { FirstFID = FileID::get(I); SourceFile = Entry; break;