[cfe-commits] r98337 - in /cfe/trunk: include/clang/Basic/IdentifierTable.h include/clang/Lex/PTHManager.h lib/Lex/PTHLexer.cpp

Kovarththanan Rajaratnam kovarththanan.rajaratnam at gmail.com
Fri Mar 12 00:23:34 PST 2010


Author: krj
Date: Fri Mar 12 02:23:34 2010
New Revision: 98337

URL: http://llvm.org/viewvc/llvm-project?rev=98337&view=rev
Log:
Switch over IdentifierInfoLookup to StringRef

Modified:
    cfe/trunk/include/clang/Basic/IdentifierTable.h
    cfe/trunk/include/clang/Lex/PTHManager.h
    cfe/trunk/lib/Lex/PTHLexer.cpp

Modified: cfe/trunk/include/clang/Basic/IdentifierTable.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/IdentifierTable.h?rev=98337&r1=98336&r2=98337&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/IdentifierTable.h (original)
+++ cfe/trunk/include/clang/Basic/IdentifierTable.h Fri Mar 12 02:23:34 2010
@@ -18,6 +18,7 @@
 #include "clang/Basic/OperatorKinds.h"
 #include "clang/Basic/TokenKinds.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/OwningPtr.h"
 #include "llvm/Support/PointerLikeTypeTraits.h"
@@ -236,9 +237,7 @@
   ///  Unlike the version in IdentifierTable, this returns a pointer instead
   ///  of a reference.  If the pointer is NULL then the IdentifierInfo cannot
   ///  be found.
-  //
-  // FIXME: Move to StringRef API.
-  virtual IdentifierInfo* get(const char *NameStart, const char *NameEnd) = 0;
+  virtual IdentifierInfo* get(llvm::StringRef Name) = 0;
 };
 
 /// \brief An abstract class used to resolve numerical identifier
@@ -292,7 +291,7 @@
 
     // No entry; if we have an external lookup, look there first.
     if (ExternalLookup) {
-      II = ExternalLookup->get(NameStart, NameEnd);
+      II = ExternalLookup->get(llvm::StringRef(NameStart, NameEnd-NameStart));
       if (II) {
         // Cache in the StringMap for subsequent lookups.
         Entry.setValue(II);
@@ -533,7 +532,7 @@
     return LHS == RHS;
   }
 };
-  
+
 template <>
 struct isPodLike<clang::Selector> { static const bool value = true; };
 

Modified: cfe/trunk/include/clang/Lex/PTHManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PTHManager.h?rev=98337&r1=98336&r2=98337&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/PTHManager.h (original)
+++ cfe/trunk/include/clang/Lex/PTHManager.h Fri Mar 12 02:23:34 2010
@@ -115,7 +115,7 @@
   ///  Unlike the version in IdentifierTable, this returns a pointer instead
   ///  of a reference.  If the pointer is NULL then the IdentifierInfo cannot
   ///  be found.
-  IdentifierInfo *get(const char *NameStart, const char *NameEnd);
+  IdentifierInfo *get(llvm::StringRef Name);
 
   /// Create - This method creates PTHManager objects.  The 'file' argument
   ///  is the name of the PTH file.  This method returns NULL upon failure.

Modified: cfe/trunk/lib/Lex/PTHLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PTHLexer.cpp?rev=98337&r1=98336&r2=98337&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PTHLexer.cpp (original)
+++ cfe/trunk/lib/Lex/PTHLexer.cpp Fri Mar 12 02:23:34 2010
@@ -549,12 +549,12 @@
   return II;
 }
 
-IdentifierInfo* PTHManager::get(const char *NameStart, const char *NameEnd) {
+IdentifierInfo* PTHManager::get(llvm::StringRef Name) {
   PTHStringIdLookup& SL = *((PTHStringIdLookup*)StringIdLookup);
   // Double check our assumption that the last character isn't '\0'.
-  assert(NameEnd==NameStart || NameStart[NameEnd-NameStart-1] != '\0');
-  PTHStringIdLookup::iterator I = SL.find(std::make_pair(NameStart,
-                                                         NameEnd - NameStart));
+  assert(Name.empty() || Name.data()[Name.size()-1] != '\0');
+  PTHStringIdLookup::iterator I = SL.find(std::make_pair(Name.data(),
+                                                         Name.size()));
   if (I == SL.end()) // No identifier found?
     return 0;
 
@@ -662,7 +662,7 @@
     CacheTy::iterator I = Cache.find(path);
 
     // If we don't get a hit in the PTH file just forward to 'stat'.
-    if (I == Cache.end()) 
+    if (I == Cache.end())
       return StatSysCallCache::stat(path, buf);
 
     const PTHStatData& Data = *I;





More information about the cfe-commits mailing list