diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-10-17 03:28:48 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-10-17 03:28:48 +0000 |
commit | 7fe60650c1133ee74a3395cf1063690e274bb7ac (patch) | |
tree | 0a4c296a0e92dfac8b277412745a0c941c6018e1 /include/clang/Basic/IdentifierTable.h | |
parent | 5a7cb84a8e806c2c6d89f33b3c615b7717d10e9e (diff) |
Add IdentiferInfo::getNameStr() -> StringRef.
Also, add getNameStart as a synonym for getName(). getName() is now deprecated,
when all clients are updated then getNameStr() should be renamed to
getName(). PR5218.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84306 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/IdentifierTable.h')
-rw-r--r-- | include/clang/Basic/IdentifierTable.h | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/include/clang/Basic/IdentifierTable.h b/include/clang/Basic/IdentifierTable.h index 84c2fc910d..ddd43688fe 100644 --- a/include/clang/Basic/IdentifierTable.h +++ b/include/clang/Basic/IdentifierTable.h @@ -75,13 +75,13 @@ public: /// This is intended to be used for string literals only: II->isStr("foo"). template <std::size_t StrLen> bool isStr(const char (&Str)[StrLen]) const { - return getLength() == StrLen-1 && !memcmp(getName(), Str, StrLen-1); + return getLength() == StrLen-1 && !memcmp(getNameStart(), Str, StrLen-1); } - /// getName - Return the actual string for this identifier. The returned - /// string is properly null terminated. + /// getNameStart - Return the beginning of the actual string for this + /// identifier. The returned string is properly null terminated. /// - const char *getName() const { + const char *getNameStart() const { if (Entry) return Entry->getKeyData(); // FIXME: This is gross. It would be best not to embed specific details // of the PTH file format here. @@ -101,8 +101,17 @@ public: // std::pair<IdentifierInfo, const char*>, where internal pointer // points to the external string data. const char* p = ((std::pair<IdentifierInfo, const char*>*) this)->second-2; - return (((unsigned) p[0]) - | (((unsigned) p[1]) << 8)) - 1; + return (((unsigned) p[0]) | (((unsigned) p[1]) << 8)) - 1; + } + + // FIXME: Deprecated. + const char *getName() const { + return getNameStart(); + } + + /// getNameStr - Return the actual identifier string. + llvm::StringRef getNameStr() const { + return llvm::StringRef(getNameStart(), getLength()); } /// hasMacroDefinition - Return true if this identifier is #defined to some @@ -463,7 +472,7 @@ public: const IdentifierInfo *Name) { llvm::SmallString<100> SelectorName; SelectorName = "set"; - SelectorName.append(Name->getName(), Name->getName()+Name->getLength()); + SelectorName += Name->getNameStr(); SelectorName[3] = toupper(SelectorName[3]); IdentifierInfo *SetterName = &Idents.get(SelectorName.data(), |