llvm::sys::fs::UniqueID UniqueID;
bool IsNamedPipe;
bool InPCH;
+ bool IsValid; // Is this \c FileEntry initialized and valid?
/// \brief The open file, if it is owned by the \p FileEntry.
mutable OwningPtr<vfs::File> File;
public:
FileEntry(llvm::sys::fs::UniqueID UniqueID, bool IsNamedPipe, bool InPCH)
- : Name(0), UniqueID(UniqueID), IsNamedPipe(IsNamedPipe), InPCH(InPCH)
+ : Name(0), UniqueID(UniqueID), IsNamedPipe(IsNamedPipe), InPCH(InPCH),
+ IsValid(false)
{}
// Add a default constructor for use with llvm::StringMap
FileEntry()
- : Name(0), UniqueID(0, 0), IsNamedPipe(false), InPCH(false)
+ : Name(0), UniqueID(0, 0), IsNamedPipe(false), InPCH(false),
+ IsValid(false)
{}
FileEntry(const FileEntry &FE) {
}
const char *getName() const { return Name; }
+ bool isValid() const { return IsValid; }
off_t getSize() const { return Size; }
unsigned getUID() const { return UID; }
const llvm::sys::fs::UniqueID &getUniqueID() const { return UniqueID; }
UniqueRealFiles.getFile(Data.UniqueID, Data.IsNamedPipe, Data.InPCH);
NamedFileEnt.setValue(&UFE);
- if (UFE.getName()) { // Already have an entry with this inode, return it.
+ if (UFE.isValid()) { // Already have an entry with this inode, return it.
// If the stat process opened the file, close it to avoid a FD leak.
if (F)
delete F;
UFE.Dir = DirInfo;
UFE.UID = NextFileUID++;
UFE.File.reset(F);
+ UFE.IsValid = true;
return &UFE;
}
UFE->closeFile();
// If we already have an entry with this inode, return it.
- if (UFE->getName())
+ if (UFE->isValid())
return UFE;
}
FileID FID = SM.getMainFileID();
if (!FID.isInvalid()) {
const FileEntry *FE = SM.getFileEntryForID(FID);
- if (FE && FE->getName())
+ if (FE && FE->isValid())
MainFilename = FE->getName();
}
}
FileID FID = SM.getFileID(Info.getLocation());
if (!FID.isInvalid()) {
const FileEntry *FE = SM.getFileEntryForID(FID);
- if (FE && FE->getName())
+ if (FE && FE->isValid())
DE.Filename = FE->getName();
}
} else {