15f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===--- FileManager.h - File System Probing and Caching --------*- C++ -*-===// 25f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 35f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// The LLVM Compiler Infrastructure 45f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 50bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// This file is distributed under the University of Illinois Open Source 60bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// License. See LICENSE.TXT for details. 75f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 85f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===// 95f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// This file defines the FileManager interface. 115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===// 135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#ifndef LLVM_CLANG_FILEMANAGER_H 155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#define LLVM_CLANG_FILEMANAGER_H 165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1739b49bcaaddb1049234fca9500c0ac02c088e23dChris Lattner#include "clang/Basic/FileSystemOptions.h" 18686775deca8b8685eb90801495880e3abdd844c2Chris Lattner#include "clang/Basic/LLVM.h" 194f32786ac45210143654390177105eb749b614e9Ted Kremenek#include "llvm/ADT/IntrusiveRefCntPtr.h" 20057e567f1b375190779e5341f42861896cdee442Douglas Gregor#include "llvm/ADT/SmallVector.h" 215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include "llvm/ADT/StringMap.h" 22458fb10ef5ba2d7b375c6c64095c1458af0a5be3Benjamin Kramer#include "llvm/ADT/StringRef.h" 2396438f319bb07d9a40564b5e01333f82c0c8a61eTed Kremenek#include "llvm/ADT/OwningPtr.h" 24f3eb9219cf4b4e80c377d37aed72d5d6d840b7bcTed Kremenek#include "llvm/Support/Allocator.h" 255f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// FIXME: Enhance libsystem to support inode and other fields in stat. 265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include <sys/types.h> 2710e286aa8d39fb51a21412850265d9dae74613eeChris Lattner 281626601b00a1feccd6b7a3f54e2991f56b659192Dylan Noblesmith#ifdef _MSC_VER 291626601b00a1feccd6b7a3f54e2991f56b659192Dylan Noblesmithtypedef unsigned short mode_t; 301626601b00a1feccd6b7a3f54e2991f56b659192Dylan Noblesmith#endif 311626601b00a1feccd6b7a3f54e2991f56b659192Dylan Noblesmith 3210e286aa8d39fb51a21412850265d9dae74613eeChris Lattnerstruct stat; 335f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 34389db16c63eec6ecfa9b235155252d8da766e94eArgyrios Kyrtzidisnamespace llvm { 35389db16c63eec6ecfa9b235155252d8da766e94eArgyrios Kyrtzidisclass MemoryBuffer; 3610e286aa8d39fb51a21412850265d9dae74613eeChris Lattnernamespace sys { class Path; } 37389db16c63eec6ecfa9b235155252d8da766e94eArgyrios Kyrtzidis} 38389db16c63eec6ecfa9b235155252d8da766e94eArgyrios Kyrtzidis 395f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang { 405f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass FileManager; 4110e286aa8d39fb51a21412850265d9dae74613eeChris Lattnerclass FileSystemStatCache; 4270042f5d1ca378138f90b7b9384023701f5d03d8David Blaikie 439b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan/// DirectoryEntry - Cached information about one directory (either on 449b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan/// the disk or in the virtual file system). 455f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 465f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass DirectoryEntry { 475f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer const char *Name; // Name of the directory. 485f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer friend class FileManager; 495f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 505f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer DirectoryEntry() : Name(0) {} 511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump const char *getName() const { return Name; } 525f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 535f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 549b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan/// FileEntry - Cached information about one file (either on the disk 559b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan/// or in the virtual file system). If the 'FD' member is valid, then 569b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan/// this FileEntry has an open file descriptor for the file. 575f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 585f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass FileEntry { 59f17765d202d1ec34ada7ff3f18d18731588143c2Chris Lattner const char *Name; // Name of the file. 605f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer off_t Size; // File size in bytes. 615f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer time_t ModTime; // Modification time of file. 625f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer const DirectoryEntry *Dir; // Directory file lives in. 635f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer unsigned UID; // A unique (small) ID for the file. 64bca6d125c77c93c7fa41798c15348175a6bb1267Ted Kremenek dev_t Device; // ID for the device containing the file. 65bca6d125c77c93c7fa41798c15348175a6bb1267Ted Kremenek ino_t Inode; // Inode number for the file. 6696438f319bb07d9a40564b5e01333f82c0c8a61eTed Kremenek mode_t FileMode; // The file mode as returned by 'stat'. 6770042f5d1ca378138f90b7b9384023701f5d03d8David Blaikie 68f9f7766846a205bc900b578f944567e679b221aaChris Lattner /// FD - The file descriptor for the file entry if it is opened and owned 69f9f7766846a205bc900b578f944567e679b221aaChris Lattner /// by the FileEntry. If not, this is set to -1. 705cc1c738b0c51af55cbfe7672c284c19f8e30eb2Chris Lattner mutable int FD; 715f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer friend class FileManager; 7270042f5d1ca378138f90b7b9384023701f5d03d8David Blaikie 735f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 7496438f319bb07d9a40564b5e01333f82c0c8a61eTed Kremenek FileEntry(dev_t device, ino_t inode, mode_t m) 75f9f7766846a205bc900b578f944567e679b221aaChris Lattner : Name(0), Device(device), Inode(inode), FileMode(m), FD(-1) {} 766bb816a3b895e9c983d89b22d510dca58a0eb75eTed Kremenek // Add a default constructor for use with llvm::StringMap 77f9f7766846a205bc900b578f944567e679b221aaChris Lattner FileEntry() : Name(0), Device(0), Inode(0), FileMode(0), FD(-1) {} 78f9f7766846a205bc900b578f944567e679b221aaChris Lattner 79f9f7766846a205bc900b578f944567e679b221aaChris Lattner FileEntry(const FileEntry &FE) { 80f9f7766846a205bc900b578f944567e679b221aaChris Lattner memcpy(this, &FE, sizeof(FE)); 81e4fed47acee9e7ca9c9cfa77c3920eec4639d7d0Chris Lattner assert(FD == -1 && "Cannot copy a file-owning FileEntry"); 82e4fed47acee9e7ca9c9cfa77c3920eec4639d7d0Chris Lattner } 8370042f5d1ca378138f90b7b9384023701f5d03d8David Blaikie 84e4fed47acee9e7ca9c9cfa77c3920eec4639d7d0Chris Lattner void operator=(const FileEntry &FE) { 85e4fed47acee9e7ca9c9cfa77c3920eec4639d7d0Chris Lattner memcpy(this, &FE, sizeof(FE)); 86e4fed47acee9e7ca9c9cfa77c3920eec4639d7d0Chris Lattner assert(FD == -1 && "Cannot assign a file-owning FileEntry"); 87f9f7766846a205bc900b578f944567e679b221aaChris Lattner } 88f9f7766846a205bc900b578f944567e679b221aaChris Lattner 89f9f7766846a205bc900b578f944567e679b221aaChris Lattner ~FileEntry(); 901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 915f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer const char *getName() const { return Name; } 925f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer off_t getSize() const { return Size; } 935f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer unsigned getUID() const { return UID; } 94bca6d125c77c93c7fa41798c15348175a6bb1267Ted Kremenek ino_t getInode() const { return Inode; } 957f1752797d4a4344b539ad9452471871c0eec64bTed Kremenek dev_t getDevice() const { return Device; } 965f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer time_t getModificationTime() const { return ModTime; } 9796438f319bb07d9a40564b5e01333f82c0c8a61eTed Kremenek mode_t getFileMode() const { return FileMode; } 981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 995f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// getDir - Return the directory the file lives in. 1005f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// 1015f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer const DirectoryEntry *getDir() const { return Dir; } 1021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 103f9f7766846a205bc900b578f944567e679b221aaChris Lattner bool operator<(const FileEntry &RHS) const { 104bca6d125c77c93c7fa41798c15348175a6bb1267Ted Kremenek return Device < RHS.Device || (Device == RHS.Device && Inode < RHS.Inode); 105bca6d125c77c93c7fa41798c15348175a6bb1267Ted Kremenek } 1065f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 1075f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1085f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// FileManager - Implements support for file system lookup, file system 1095f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// caching, and directory search management. This also handles more advanced 1105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// properties, such as uniquing files based on "inode", so that a file with two 1115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// names (e.g. symlinked) will be treated as a single file. 1125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 113c93dc7889644293e318e19d82830ea2acc45b678Dylan Noblesmithclass FileManager : public RefCountedBase<FileManager> { 11439b49bcaaddb1049234fca9500c0ac02c088e23dChris Lattner FileSystemOptions FileSystemOpts; 1159b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan 1166bb816a3b895e9c983d89b22d510dca58a0eb75eTed Kremenek class UniqueDirContainer; 1176bb816a3b895e9c983d89b22d510dca58a0eb75eTed Kremenek class UniqueFileContainer; 1186bb816a3b895e9c983d89b22d510dca58a0eb75eTed Kremenek 11970042f5d1ca378138f90b7b9384023701f5d03d8David Blaikie /// UniqueRealDirs/UniqueRealFiles - Cache for existing real 12070042f5d1ca378138f90b7b9384023701f5d03d8David Blaikie /// directories/files. 1215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// 1229b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan UniqueDirContainer &UniqueRealDirs; 1239b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan UniqueFileContainer &UniqueRealFiles; 1246bb816a3b895e9c983d89b22d510dca58a0eb75eTed Kremenek 1259b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan /// \brief The virtual directories that we have allocated. For each 1269b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan /// virtual file (e.g. foo/bar/baz.cpp), we add all of its parent 1279b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan /// directories (foo/ and foo/bar/) here. 128686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<DirectoryEntry*, 4> VirtualDirectoryEntries; 1299b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan /// \brief The virtual files that we have allocated. 130686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<FileEntry*, 4> VirtualFileEntries; 1319b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan 1329b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan /// SeenDirEntries/SeenFileEntries - This is a cache that maps paths 1339b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan /// to directory/file entries (either real or virtual) we have 1349b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan /// looked up. The actual Entries for real directories/files are 1359b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan /// owned by UniqueRealDirs/UniqueRealFiles above, while the Entries 1369b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan /// for virtual directories/files are owned by 1379b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan /// VirtualDirectoryEntries/VirtualFileEntries above. 1385f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// 1399b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan llvm::StringMap<DirectoryEntry*, llvm::BumpPtrAllocator> SeenDirEntries; 1409b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan llvm::StringMap<FileEntry*, llvm::BumpPtrAllocator> SeenFileEntries; 1411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1425f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// NextFileUID - Each FileEntry we create is assigned a unique ID #. 1435f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// 1445f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer unsigned NextFileUID; 1451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1465f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // Statistics. 1475f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer unsigned NumDirLookups, NumFileLookups; 1485f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer unsigned NumDirCacheMisses, NumFileCacheMisses; 1491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 150fc7052d4a241ee6fc70afea7c1c9560147f0a49cTed Kremenek // Caching. 1516f42b62b6194f53bcbc349f5d17388e1936535d7Dylan Noblesmith OwningPtr<FileSystemStatCache> StatCache; 1521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 153898a061f69e1145bf89a987c08203132b9922a3cChris Lattner bool getStatValue(const char *Path, struct stat &StatBuf, 154898a061f69e1145bf89a987c08203132b9922a3cChris Lattner int *FileDescriptor); 1559b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan 1569b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan /// Add all ancestors of the given path (pointing to either a file 1579b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan /// or a directory) as virtual directories. 158686775deca8b8685eb90801495880e3abdd844c2Chris Lattner void addAncestorsAsVirtualDirs(StringRef Path); 1599b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan 1605f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 1617ad97ffa631af6ad678c79b38341ac995f347ce9Chris Lattner FileManager(const FileSystemOptions &FileSystemOpts); 1626bb816a3b895e9c983d89b22d510dca58a0eb75eTed Kremenek ~FileManager(); 1635f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 16410e286aa8d39fb51a21412850265d9dae74613eeChris Lattner /// \brief Installs the provided FileSystemStatCache object within 1659b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan /// the FileManager. 16652e7108f51a4a9f4d6e84f33fb594d06e1d79560Douglas Gregor /// 16752e7108f51a4a9f4d6e84f33fb594d06e1d79560Douglas Gregor /// Ownership of this object is transferred to the FileManager. 16852e7108f51a4a9f4d6e84f33fb594d06e1d79560Douglas Gregor /// 16952e7108f51a4a9f4d6e84f33fb594d06e1d79560Douglas Gregor /// \param statCache the new stat cache to install. Ownership of this 17052e7108f51a4a9f4d6e84f33fb594d06e1d79560Douglas Gregor /// object is transferred to the FileManager. 17152e7108f51a4a9f4d6e84f33fb594d06e1d79560Douglas Gregor /// 17252e7108f51a4a9f4d6e84f33fb594d06e1d79560Douglas Gregor /// \param AtBeginning whether this new stat cache must be installed at the 17352e7108f51a4a9f4d6e84f33fb594d06e1d79560Douglas Gregor /// beginning of the chain of stat caches. Otherwise, it will be added to 17452e7108f51a4a9f4d6e84f33fb594d06e1d79560Douglas Gregor /// the end of the chain. 17510e286aa8d39fb51a21412850265d9dae74613eeChris Lattner void addStatCache(FileSystemStatCache *statCache, bool AtBeginning = false); 17652e7108f51a4a9f4d6e84f33fb594d06e1d79560Douglas Gregor 17710e286aa8d39fb51a21412850265d9dae74613eeChris Lattner /// \brief Removes the specified FileSystemStatCache object from the manager. 17810e286aa8d39fb51a21412850265d9dae74613eeChris Lattner void removeStatCache(FileSystemStatCache *statCache); 1799b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan 1809b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan /// getDirectory - Lookup, cache, and verify the specified directory 1819b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan /// (real or virtual). This returns NULL if the directory doesn't exist. 1821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 1836e975c4517958bcc11c834336d340797356058dbDouglas Gregor /// \param CacheFailure If true and the file does not exist, we'll cache 1846e975c4517958bcc11c834336d340797356058dbDouglas Gregor /// the failure to find this file. 1856e975c4517958bcc11c834336d340797356058dbDouglas Gregor const DirectoryEntry *getDirectory(StringRef DirName, 1866e975c4517958bcc11c834336d340797356058dbDouglas Gregor bool CacheFailure = true); 1871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1883cd0128ce49abe658d1858c541e836e57959e04aArgyrios Kyrtzidis /// \brief Lookup, cache, and verify the specified file (real or 1899b555ea217565ac0f8bf7255b29496916cb03476Zhanyong Wan /// virtual). This returns NULL if the file doesn't exist. 1901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 1916e975c4517958bcc11c834336d340797356058dbDouglas Gregor /// \param OpenFile if true and the file exists, it will be opened. 1926e975c4517958bcc11c834336d340797356058dbDouglas Gregor /// 1936e975c4517958bcc11c834336d340797356058dbDouglas Gregor /// \param CacheFailure If true and the file does not exist, we'll cache 1946e975c4517958bcc11c834336d340797356058dbDouglas Gregor /// the failure to find this file. 1956e975c4517958bcc11c834336d340797356058dbDouglas Gregor const FileEntry *getFile(StringRef Filename, bool OpenFile = false, 1966e975c4517958bcc11c834336d340797356058dbDouglas Gregor bool CacheFailure = true); 1971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1981afb661bc5444462a246cefa0effa61ef25fab29Jonathan D. Turner /// \brief Returns the current file system options 1991afb661bc5444462a246cefa0effa61ef25fab29Jonathan D. Turner const FileSystemOptions &getFileSystemOptions() { return FileSystemOpts; } 2001afb661bc5444462a246cefa0effa61ef25fab29Jonathan D. Turner 201057e567f1b375190779e5341f42861896cdee442Douglas Gregor /// \brief Retrieve a file entry for a "virtual" file that acts as 202057e567f1b375190779e5341f42861896cdee442Douglas Gregor /// if there were a file with the given name on disk. The file 203057e567f1b375190779e5341f42861896cdee442Douglas Gregor /// itself is not accessed. 204686775deca8b8685eb90801495880e3abdd844c2Chris Lattner const FileEntry *getVirtualFile(StringRef Filename, off_t Size, 20539b49bcaaddb1049234fca9500c0ac02c088e23dChris Lattner time_t ModificationTime); 206389db16c63eec6ecfa9b235155252d8da766e94eArgyrios Kyrtzidis 207389db16c63eec6ecfa9b235155252d8da766e94eArgyrios Kyrtzidis /// \brief Open the specified file as a MemoryBuffer, returning a new 208389db16c63eec6ecfa9b235155252d8da766e94eArgyrios Kyrtzidis /// MemoryBuffer if successful, otherwise returning null. 209389db16c63eec6ecfa9b235155252d8da766e94eArgyrios Kyrtzidis llvm::MemoryBuffer *getBufferForFile(const FileEntry *Entry, 21075dfb65c38d51772df9a00ce2d2feeefd55667adChris Lattner std::string *ErrorStr = 0); 211686775deca8b8685eb90801495880e3abdd844c2Chris Lattner llvm::MemoryBuffer *getBufferForFile(StringRef Filename, 21275dfb65c38d51772df9a00ce2d2feeefd55667adChris Lattner std::string *ErrorStr = 0); 213389db16c63eec6ecfa9b235155252d8da766e94eArgyrios Kyrtzidis 2147dbafb3ade491a41100c97597209455ee10c537dAnders Carlsson // getNoncachedStatValue - Will get the 'stat' information for the given path. 2157dbafb3ade491a41100c97597209455ee10c537dAnders Carlsson // If the path is relative, it will be resolved against the WorkingDir of the 2167dbafb3ade491a41100c97597209455ee10c537dAnders Carlsson // FileManager's FileSystemOptions. 217686775deca8b8685eb90801495880e3abdd844c2Chris Lattner bool getNoncachedStatValue(StringRef Path, struct stat &StatBuf); 2187dbafb3ade491a41100c97597209455ee10c537dAnders Carlsson 219389db16c63eec6ecfa9b235155252d8da766e94eArgyrios Kyrtzidis /// \brief If path is not absolute and FileSystemOptions set the working 220389db16c63eec6ecfa9b235155252d8da766e94eArgyrios Kyrtzidis /// directory, the path is modified to be relative to the given 221389db16c63eec6ecfa9b235155252d8da766e94eArgyrios Kyrtzidis /// working directory. 222686775deca8b8685eb90801495880e3abdd844c2Chris Lattner void FixupRelativePath(SmallVectorImpl<char> &path) const; 223d47aad92ccfb6c2cf5921f8fefddd7e541dc9bb3Anders Carlsson 224cfbf1c7536e016dc275139dd842d4a5f059a749fDouglas Gregor /// \brief Produce an array mapping from the unique IDs assigned to each 225cfbf1c7536e016dc275139dd842d4a5f059a749fDouglas Gregor /// file to the corresponding FileEntry pointer. 226cfbf1c7536e016dc275139dd842d4a5f059a749fDouglas Gregor void GetUniqueIDMapping( 227686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVectorImpl<const FileEntry *> &UIDToFiles) const; 22870042f5d1ca378138f90b7b9384023701f5d03d8David Blaikie 2295f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void PrintStats() const; 2305f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 2315f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2325f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer} // end namespace clang 2335f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2345f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif 235