Use StringRef.

llvm-svn: 84786
This commit is contained in:
Devang Patel 2009-10-21 21:57:13 +00:00
parent 854530a7dd
commit 2505c1e17a
2 changed files with 8 additions and 7 deletions

View File

@ -287,14 +287,14 @@ private:
public: public:
/// registerMDKind - Register a new metadata kind and return its ID. /// registerMDKind - Register a new metadata kind and return its ID.
/// A metadata kind can be registered only once. /// A metadata kind can be registered only once.
unsigned registerMDKind(const char *Name); unsigned registerMDKind(const StringRef Name);
/// getMDKind - Return metadata kind. If the requested metadata kind /// getMDKind - Return metadata kind. If the requested metadata kind
/// is not registered then return 0. /// is not registered then return 0.
unsigned getMDKind(const char *Name); unsigned getMDKind(const StringRef Name) const;
/// isValidName - Return true if Name is a valid custom metadata handler name. /// isValidName - Return true if Name is a valid custom metadata handler name.
bool isValidName(const char *Name); static bool isValidName(const StringRef Name);
/// getMD - Get the metadata of given kind attached to an Instruction. /// getMD - Get the metadata of given kind attached to an Instruction.
/// If the metadata is not found then return 0. /// If the metadata is not found then return 0.

View File

@ -250,7 +250,7 @@ NamedMDNode::~NamedMDNode() {
/// registerMDKind - Register a new metadata kind and return its ID. /// registerMDKind - Register a new metadata kind and return its ID.
/// A metadata kind can be registered only once. /// A metadata kind can be registered only once.
unsigned MetadataContext::registerMDKind(const char *Name) { unsigned MetadataContext::registerMDKind(const StringRef Name) {
assert(isValidName(Name) && "Invalid custome metadata name!"); assert(isValidName(Name) && "Invalid custome metadata name!");
unsigned Count = MDHandlerNames.size(); unsigned Count = MDHandlerNames.size();
assert(MDHandlerNames.count(Name) == 0 && "Already registered MDKind!"); assert(MDHandlerNames.count(Name) == 0 && "Already registered MDKind!");
@ -258,7 +258,8 @@ unsigned MetadataContext::registerMDKind(const char *Name) {
} }
/// isValidName - Return true if Name is a valid custom metadata handler name. /// isValidName - Return true if Name is a valid custom metadata handler name.
bool MetadataContext::isValidName(const char *Name) { bool MetadataContext::isValidName(const StringRef MDName) {
const char *Name = MDName.data();
if (!Name) if (!Name)
return false; return false;
@ -280,8 +281,8 @@ bool MetadataContext::isValidName(const char *Name) {
/// getMDKind - Return metadata kind. If the requested metadata kind /// getMDKind - Return metadata kind. If the requested metadata kind
/// is not registered then return 0. /// is not registered then return 0.
unsigned MetadataContext::getMDKind(const char *Name) { unsigned MetadataContext::getMDKind(const StringRef Name) const {
StringMap<unsigned>::iterator I = MDHandlerNames.find(Name); StringMap<unsigned>::const_iterator I = MDHandlerNames.find(Name);
if (I == MDHandlerNames.end()) { if (I == MDHandlerNames.end()) {
assert(isValidName(Name) && "Invalid custome metadata name!"); assert(isValidName(Name) && "Invalid custome metadata name!");
return 0; return 0;