forked from OSchip/llvm-project
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. llvm-svn: 84306
This commit is contained in:
parent
1623c28f36
commit
cc2f79b44b
|
@ -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,
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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(),
|
||||
|
|
Loading…
Reference in New Issue