///
/// 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.
// 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;
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;
}
// 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;
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;