[cfe-commits] r39333 - in /cfe/cfe/trunk: Basic/FileManager.cpp Lex/HeaderSearch.cpp Lex/IdentifierTable.cpp Lex/Preprocessor.cpp include/clang/Lex/IdentifierTable.h

sabre at cs.uiuc.edu sabre at cs.uiuc.edu
Wed Jul 11 09:43:14 PDT 2007


Author: sabre
Date: Wed Jul 11 11:43:13 2007
New Revision: 39333

URL: http://llvm.org/viewvc/llvm-project?rev=39333&view=rev
Log:
adjust to CStringMap interface change.

Modified:
    cfe/cfe/trunk/Basic/FileManager.cpp
    cfe/cfe/trunk/Lex/HeaderSearch.cpp
    cfe/cfe/trunk/Lex/IdentifierTable.cpp
    cfe/cfe/trunk/Lex/Preprocessor.cpp
    cfe/cfe/trunk/include/clang/Lex/IdentifierTable.h

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

==============================================================================
--- cfe/cfe/trunk/Basic/FileManager.cpp (original)
+++ cfe/cfe/trunk/Basic/FileManager.cpp Wed Jul 11 11:43:13 2007
@@ -37,20 +37,22 @@
 const DirectoryEntry *FileManager::getDirectory(const char *NameStart,
                                                 const char *NameEnd) {
   ++NumDirLookups;
-  DirectoryEntry *&NamedDirEnt =DirEntries.GetOrCreateValue(NameStart, NameEnd);
+  StringMapEntry<DirectoryEntry *> &NamedDirEnt =
+    DirEntries.GetOrCreateValue(NameStart, NameEnd);
   
   // See if there is already an entry in the map.
-  if (NamedDirEnt)
-    return NamedDirEnt == NON_EXISTANT_DIR ? 0 : NamedDirEnt;
+  if (NamedDirEnt.getValue())
+    return NamedDirEnt.getValue() == NON_EXISTANT_DIR
+              ? 0 : NamedDirEnt.getValue();
   
   ++NumDirCacheMisses;
   
   // By default, initialize it to invalid.
-  NamedDirEnt = NON_EXISTANT_DIR;
+  NamedDirEnt.setValue(NON_EXISTANT_DIR);
   
   // Get the null-terminated directory name as stored as the key of the
   // DirEntries map.
-  const char *InterndDirName = DirEntries.GetKeyForValueInMap(NamedDirEnt);
+  const char *InterndDirName = NamedDirEnt.getKeyData();
   
   // Check to see if the directory exists.
   struct stat StatBuf;
@@ -63,13 +65,14 @@
   DirectoryEntry &UDE = 
     UniqueDirs[std::make_pair(StatBuf.st_dev, StatBuf.st_ino)];
   
-  if (UDE.getName())  // Already have an entry with this inode, return it.
-    return NamedDirEnt = &UDE;
+  NamedDirEnt.setValue(&UDE);
+  if (UDE.getName()) // Already have an entry with this inode, return it.
+    return &UDE;
   
   // Otherwise, we don't have this directory yet, add it.  We use the string
   // key from the DirEntries map as the string.
   UDE.Name  = InterndDirName;
-  return NamedDirEnt = &UDE;
+  return &UDE;
 }
 
 /// NON_EXISTANT_FILE - A special value distinct from null that is used to
@@ -84,16 +87,18 @@
   ++NumFileLookups;
   
   // See if there is already an entry in the map.
-  FileEntry *&NamedFileEnt = FileEntries.GetOrCreateValue(NameStart, NameEnd);
+  StringMapEntry<FileEntry *> &NamedFileEnt =
+    FileEntries.GetOrCreateValue(NameStart, NameEnd);
 
   // See if there is already an entry in the map.
-  if (NamedFileEnt)
-    return NamedFileEnt == NON_EXISTANT_FILE ? 0 : NamedFileEnt;
+  if (NamedFileEnt.getValue())
+    return NamedFileEnt.getValue() == NON_EXISTANT_FILE
+                 ? 0 : NamedFileEnt.getValue();
   
   ++NumFileCacheMisses;
 
   // By default, initialize it to invalid.
-  NamedFileEnt = NON_EXISTANT_FILE;
+  NamedFileEnt.setValue(NON_EXISTANT_FILE);
 
   // Figure out what directory it is in.   If the string contains a / in it,
   // strip off everything after it.
@@ -117,7 +122,7 @@
   
   // Get the null-terminated file name as stored as the key of the
   // FileEntries map.
-  const char *InterndFileName = FileEntries.GetKeyForValueInMap(NamedFileEnt);
+  const char *InterndFileName = NamedFileEnt.getKeyData();
   
   // FIXME: Use the directory info to prune this, before doing the stat syscall.
   // FIXME: This will reduce the # syscalls.
@@ -137,8 +142,9 @@
   // This occurs when one dir is symlinked to another, for example.
   FileEntry &UFE = UniqueFiles[std::make_pair(StatBuf.st_dev, StatBuf.st_ino)];
   
+  NamedFileEnt.setValue(&UFE);
   if (UFE.getName())  // Already have an entry with this inode, return it.
-    return NamedFileEnt = &UFE;
+    return &UFE;
 
   // Otherwise, we don't have this directory yet, add it.
   // FIXME: Change the name to be a char* that points back to the 'FileEntries'
@@ -148,7 +154,7 @@
   UFE.ModTime = StatBuf.st_mtime;
   UFE.Dir     = DirInfo;
   UFE.UID     = NextFileUID++;
-  return NamedFileEnt = &UFE;
+  return &UFE;
 }
 
 void FileManager::PrintStats() const {

Modified: cfe/cfe/trunk/Lex/HeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/HeaderSearch.cpp?rev=39333&r1=39332&r2=39333&view=diff

==============================================================================
--- cfe/cfe/trunk/Lex/HeaderSearch.cpp (original)
+++ cfe/cfe/trunk/Lex/HeaderSearch.cpp Wed Jul 11 11:43:13 2007
@@ -62,11 +62,11 @@
   const char *SlashPos = std::find(FilenameStart, FilenameEnd, '/');
   if (SlashPos == FilenameEnd) return 0;
   
-  const DirectoryEntry *&CacheLookup =
+  StringMapEntry<const DirectoryEntry *> &CacheLookup =
     FrameworkMap.GetOrCreateValue(FilenameStart, SlashPos);
   
   // If it is some other directory, fail.
-  if (CacheLookup && CacheLookup != Dir)
+  if (CacheLookup.getValue() && CacheLookup.getValue() != Dir)
     return 0;
 
   // FrameworkName = "/System/Library/Frameworks/"
@@ -81,7 +81,7 @@
   // FrameworkName = "/System/Library/Frameworks/Cocoa.framework/"
   FrameworkName += ".framework/";
  
-  if (CacheLookup == 0) {
+  if (CacheLookup.getValue() == 0) {
     ++NumFrameworkLookups;
     
     // If the framework dir doesn't exist, we fail.
@@ -91,7 +91,7 @@
     
     // Otherwise, if it does, remember that this is the right direntry for this
     // framework.
-    CacheLookup = Dir;
+    CacheLookup.setValue(Dir);
   }
   
   // Check "/System/Library/Frameworks/Cocoa.framework/Headers/file.h"
@@ -222,15 +222,18 @@
   FrameworkName.append(FilenameStart, SlashPos);
   FrameworkName += ".framework/";
 
-  const DirectoryEntry *&CacheLookup =
+  StringMapEntry<const DirectoryEntry *> &CacheLookup =
     FrameworkMap.GetOrCreateValue(FilenameStart, SlashPos);
   
   // Some other location?
-  if (CacheLookup && strcmp(CacheLookup->getName(), FrameworkName.c_str()) != 0)
+  if (CacheLookup.getValue() &&
+      CacheLookup.getKeyLength() == FrameworkName.size() &&
+      memcmp(CacheLookup.getKeyData(), &FrameworkName[0],
+             CacheLookup.getKeyLength()) != 0)
     return 0;
   
   // Cache subframework.
-  if (CacheLookup == 0) {
+  if (CacheLookup.getValue() == 0) {
     ++NumSubFrameworkLookups;
     
     // If the framework dir doesn't exist, we fail.
@@ -240,7 +243,7 @@
     
     // Otherwise, if it does, remember that this is the right direntry for this
     // framework.
-    CacheLookup = Dir;
+    CacheLookup.setValue(Dir);
   }
   
   const FileEntry *FE = 0;

Modified: cfe/cfe/trunk/Lex/IdentifierTable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/IdentifierTable.cpp?rev=39333&r1=39332&r2=39333&view=diff

==============================================================================
--- cfe/cfe/trunk/Lex/IdentifierTable.cpp (original)
+++ cfe/cfe/trunk/Lex/IdentifierTable.cpp Wed Jul 11 11:43:13 2007
@@ -154,8 +154,8 @@
 public:
   StatsVisitor(unsigned &idLenTotal, unsigned &maxIDLen)
     : IDLenTotal(idLenTotal), MaxIDLen(maxIDLen) {}
-  void Visit(const char *Key, void *Value) const {
-    unsigned IdLen = strlen(Key);
+  void Visit(const char *Key, StringMapEntryBase *Value) const {
+    unsigned IdLen = Value->getKeyLength();
     IDLenTotal += IdLen;
     if (MaxIDLen < IdLen)
       MaxIDLen = IdLen;

Modified: cfe/cfe/trunk/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/Preprocessor.cpp?rev=39333&r1=39332&r2=39333&view=diff

==============================================================================
--- cfe/cfe/trunk/Lex/Preprocessor.cpp (original)
+++ cfe/cfe/trunk/Lex/Preprocessor.cpp Wed Jul 11 11:43:13 2007
@@ -891,8 +891,9 @@
   Preprocessor &PP;
   UnusedIdentifierReporter(Preprocessor &pp) : PP(pp) {}
 
-  void Visit(const char *Key, void *Value) const {
-    IdentifierInfo &II = *static_cast<IdentifierInfo*>(Value);
+  void Visit(const char *Key, StringMapEntryBase *Value) const {
+    IdentifierInfo &II =
+      static_cast<StringMapEntry<IdentifierInfo>*>(Value)->getValue();
     if (II.getMacroInfo() && !II.getMacroInfo()->isUsed())
       PP.Diag(II.getMacroInfo()->getDefinitionLoc(), diag::pp_macro_not_used);
   }

Modified: cfe/cfe/trunk/include/clang/Lex/IdentifierTable.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Lex/IdentifierTable.h?rev=39333&r1=39332&r2=39333&view=diff

==============================================================================
--- cfe/cfe/trunk/include/clang/Lex/IdentifierTable.h (original)
+++ cfe/cfe/trunk/include/clang/Lex/IdentifierTable.h Wed Jul 11 11:43:13 2007
@@ -141,7 +141,7 @@
   /// get - Return the identifier token info for the specified named identifier.
   ///
   IdentifierInfo &get(const char *NameStart, const char *NameEnd) {
-    return HashTable.GetOrCreateValue(NameStart, NameEnd);
+    return HashTable.GetOrCreateValue(NameStart, NameEnd).getValue();
   }
   
   IdentifierInfo &get(const char *Name) {





More information about the cfe-commits mailing list