diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 0b689c7de9d3..19e7519d61f0 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -101,7 +101,7 @@ public: /// and that it be a simple identifier. const char *getNameAsCString() const { assert(getIdentifier() && "Name is not a simple identifier"); - return getIdentifier()->getName(); + return getIdentifier()->getNameStart(); } /// getDeclName - Get the actual, stored name of the declaration, diff --git a/clang/include/clang/AST/DeclObjC.h b/clang/include/clang/AST/DeclObjC.h index 2b12bb5c1b6d..f546e4cd27c6 100644 --- a/clang/include/clang/AST/DeclObjC.h +++ b/clang/include/clang/AST/DeclObjC.h @@ -947,13 +947,17 @@ public: /// getNameAsCString - Get the name of identifier for the class /// interface associated with this implementation as a C string /// (const char*). + // + // FIXME: Move to StringRef API. const char *getNameAsCString() const { - return Id ? Id->getName() : ""; + return Id ? Id->getNameStart() : ""; } /// @brief Get the name of the class associated with this interface. + // + // FIXME: Move to StringRef API. std::string getNameAsString() const { - return Id ? Id->getName() : ""; + return Id ? Id->getNameStr() : ""; } static bool classof(const Decl *D) { return D->getKind() == ObjCCategoryImpl;} @@ -998,12 +1002,16 @@ public: /// getNameAsCString - Get the name of identifier for the class /// interface associated with this implementation as a C string /// (const char*). + // + // FIXME: Move to StringRef API. const char *getNameAsCString() const { assert(getIdentifier() && "Name is not a simple identifier"); - return getIdentifier()->getName(); + return getIdentifier()->getNameStart(); } /// @brief Get the name of the class associated with this interface. + // + // FIXME: Move to StringRef API. std::string getNameAsString() const { return getClassInterface()->getNameAsString(); } diff --git a/clang/include/clang/Basic/IdentifierTable.h b/clang/include/clang/Basic/IdentifierTable.h index 84c2fc910d11..ddd43688fe62 100644 --- a/clang/include/clang/Basic/IdentifierTable.h +++ b/clang/include/clang/Basic/IdentifierTable.h @@ -75,13 +75,13 @@ public: /// This is intended to be used for string literals only: II->isStr("foo"). template 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, where internal pointer // points to the external string data. const char* p = ((std::pair*) 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(),