aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>2010-03-12 08:23:34 +0000
committerKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>2010-03-12 08:23:34 +0000
commit700030ebddb987936d4fee14d9412821d96e4840 (patch)
tree6417c29ed239dd6ddacc1d8354efb9a87d740cb3
parent0faede6f31b07bcec7b776f2b420c3ea9bb3e58c (diff)
Switch over IdentifierInfoLookup to StringRef
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98337 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/IdentifierTable.h9
-rw-r--r--include/clang/Lex/PTHManager.h2
-rw-r--r--lib/Lex/PTHLexer.cpp10
3 files changed, 10 insertions, 11 deletions
diff --git a/include/clang/Basic/IdentifierTable.h b/include/clang/Basic/IdentifierTable.h
index 75a7b8192c..edbfeccea3 100644
--- a/include/clang/Basic/IdentifierTable.h
+++ b/include/clang/Basic/IdentifierTable.h
@@ -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; };
diff --git a/include/clang/Lex/PTHManager.h b/include/clang/Lex/PTHManager.h
index ac5594e55d..5e8a4f144c 100644
--- a/include/clang/Lex/PTHManager.h
+++ b/include/clang/Lex/PTHManager.h
@@ -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.
diff --git a/lib/Lex/PTHLexer.cpp b/lib/Lex/PTHLexer.cpp
index a64008ab18..3b949d0ab4 100644
--- a/lib/Lex/PTHLexer.cpp
+++ b/lib/Lex/PTHLexer.cpp
@@ -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;