[cfe-commits] r45171 - in /cfe/trunk: Basic/FileManager.cpp include/clang/Basic/FileManager.h

Ted Kremenek kremenek at apple.com
Tue Dec 18 12:45:26 PST 2007


Author: kremenek
Date: Tue Dec 18 14:45:25 2007
New Revision: 45171

URL: http://llvm.org/viewvc/llvm-project?rev=45171&view=rev
Log:
Added to FileEntry a pointer to the <dev_t,ino_t> pair for the file, and
accessors to FileEntry to query these values.

Modified:
    cfe/trunk/Basic/FileManager.cpp
    cfe/trunk/include/clang/Basic/FileManager.h

Modified: cfe/trunk/Basic/FileManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Basic/FileManager.cpp?rev=45171&r1=45170&r2=45171&view=diff

==============================================================================
--- cfe/trunk/Basic/FileManager.cpp (original)
+++ cfe/trunk/Basic/FileManager.cpp Tue Dec 18 14:45:25 2007
@@ -65,7 +65,7 @@
     return 0;
   
   // It exists.  See if we have already opened a directory with the same inode.
-  // This occurs when one dir is symlinked to another, for example.
+  // This occurs when one dir is symlinked to another, for example.    
   DirectoryEntry &UDE = 
     UniqueDirs[std::make_pair(StatBuf.st_dev, StatBuf.st_ino)];
   
@@ -144,7 +144,12 @@
   
   // It exists.  See if we have already opened a directory with the same inode.
   // This occurs when one dir is symlinked to another, for example.
-  FileEntry &UFE = UniqueFiles[std::make_pair(StatBuf.st_dev, StatBuf.st_ino)];
+  std::pair<FileEntryMap::iterator,bool> X = 
+    UniqueFiles.insert(FileEntryMap::value_type(std::make_pair(StatBuf.st_dev,
+                                                               StatBuf.st_ino),
+                                                FileEntry()));
+                          
+  FileEntry &UFE = X.first->second;
   
   NamedFileEnt.setValue(&UFE);
   if (UFE.getName())  // Already have an entry with this inode, return it.
@@ -158,6 +163,7 @@
   UFE.ModTime = StatBuf.st_mtime;
   UFE.Dir     = DirInfo;
   UFE.UID     = NextFileUID++;
+  UFE.InoDev  = &X.first->first;
   return &UFE;
 }
 

Modified: cfe/trunk/include/clang/Basic/FileManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileManager.h?rev=45171&r1=45170&r2=45171&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/FileManager.h (original)
+++ cfe/trunk/include/clang/Basic/FileManager.h Tue Dec 18 14:45:25 2007
@@ -42,13 +42,16 @@
   time_t ModTime;             // Modification time of file.
   const DirectoryEntry *Dir;  // Directory file lives in.
   unsigned UID;               // A unique (small) ID for the file.
+  const std::pair<dev_t, ino_t>* InoDev; // Pointer to inode/device number pair. 
   friend class FileManager;
 public:
-  FileEntry() : Name(0) {}
+  FileEntry() : Name(0), InoDev(NULL) {}
   
   const char *getName() const { return Name; }
   off_t getSize() const { return Size; }
   unsigned getUID() const { return UID; }
+  ino_t getInode() const { return InoDev->second; }
+  dev_t getDev() const { return InoDev->first; }
   time_t getModificationTime() const { return ModTime; }
   
   /// getDir - Return the directory the file lives in.
@@ -66,7 +69,9 @@
   /// UniqueDirs/UniqueFiles - Cache from ID's to existing directories/files.
   ///
   std::map<std::pair<dev_t, ino_t>, DirectoryEntry> UniqueDirs;
-  std::map<std::pair<dev_t, ino_t>, FileEntry> UniqueFiles;
+  
+  typedef std::map<std::pair<dev_t, ino_t>, FileEntry> FileEntryMap;
+  FileEntryMap UniqueFiles;
   
   /// DirEntries/FileEntries - This is a cache of directory/file entries we have
   /// looked up.  The actual Entry is owned by UniqueFiles/UniqueDirs above.





More information about the cfe-commits mailing list