]> granicus.if.org Git - clang/commitdiff
Switch over IdentifierInfoLookup to StringRef
authorKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>
Fri, 12 Mar 2010 08:23:34 +0000 (08:23 +0000)
committerKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>
Fri, 12 Mar 2010 08:23:34 +0000 (08:23 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98337 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/IdentifierTable.h
include/clang/Lex/PTHManager.h
lib/Lex/PTHLexer.cpp

index 75a7b8192c5af04138679719b59875d2291ceccf..edbfeccea3c9327e8f9b6660b0e9c0705b525d76 100644 (file)
@@ -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 @@ public:
   ///  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 @@ public:
 
     // 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 @@ struct DenseMapInfo<clang::Selector> {
     return LHS == RHS;
   }
 };
-  
+
 template <>
 struct isPodLike<clang::Selector> { static const bool value = true; };
 
index ac5594e55d7d5dd255d4e3bbda0db025311e97d4..5e8a4f144c96d0310aaccc06769e42bfa81efdbc 100644 (file)
@@ -115,7 +115,7 @@ public:
   ///  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.
index a64008ab1806a842247e55aefa9155871bafaa74..3b949d0ab40a15c3db36f856a4d9f241f3a02d01 100644 (file)
@@ -549,12 +549,12 @@ IdentifierInfo* PTHManager::LazilyCreateIdentifierInfo(unsigned PersistentID) {
   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 @@ public:
     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;