diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-07-29 18:43:40 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-07-29 18:43:40 +0000 |
commit | 3dadc85330d8f548b49f97d7e2fa62c73f7463dd (patch) | |
tree | a8df023b52aed20482959b3f92db0fb6f57e1ce5 /lib/Basic/SourceManager.cpp | |
parent | 547cca81ad792cf138867ab97929f247a77062b5 (diff) | |
download | clang-3dadc85330d8f548b49f97d7e2fa62c73f7463dd.tar.gz |
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
Diffstat (limited to 'lib/Basic/SourceManager.cpp')
-rw-r--r-- | lib/Basic/SourceManager.cpp | 33 |
1 files changed, 16 insertions, 17 deletions
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<ino_t> getActualFileInode(const FileEntry *File) { +static Optional<uint64_t> 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<ino_t> SourceFileInode; + Optional<uint64_t> SourceFileUID; Optional<StringRef> 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<ino_t> MainFileInode = getActualFileInode(MainFile)) { - if (*SourceFileInode == *MainFileInode) { + SourceFileUID = getActualFileUID(SourceFile); + if (SourceFileUID) { + if (Optional<uint64_t> 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<ino_t> EntryInode = getActualFileInode(Entry)) { - if (*SourceFileInode == *EntryInode) { + if (Optional<uint64_t> EntryUID = getActualFileUID(Entry)) { + if (*SourceFileUID == *EntryUID) { FirstFID = FileID::get(I); SourceFile = Entry; break; |