From 5bf78579bd275c4e67dc720156c3a6a7da367e40 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Sat, 17 Oct 2009 18:12:29 +0000 Subject: Rewrite AttributeList::getKind to use StringRef API. llvm-svn: 84339 --- clang/lib/Parse/AttributeList.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'clang/lib/Parse/AttributeList.cpp') diff --git a/clang/lib/Parse/AttributeList.cpp b/clang/lib/Parse/AttributeList.cpp index 2ee41bc3eb8..29e44caba64 100644 --- a/clang/lib/Parse/AttributeList.cpp +++ b/clang/lib/Parse/AttributeList.cpp @@ -45,18 +45,15 @@ AttributeList::~AttributeList() { } AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) { - const char *Str = Name->getName(); - unsigned Len = Name->getLength(); + llvm::StringRef AttrName = Name->getNameStr(); // Normalize the attribute name, __foo__ becomes foo. - if (Len > 4 && Str[0] == '_' && Str[1] == '_' && - Str[Len - 2] == '_' && Str[Len - 1] == '_') { - Str += 2; - Len -= 4; - } + if (AttrName.startswith("__") && AttrName.endswith("__")) + AttrName = AttrName.substr(2, AttrName.size() - 4); // FIXME: Hand generating this is neither smart nor efficient. - switch (Len) { + const char *Str = AttrName.data(); + switch (AttrName.size()) { case 4: if (!memcmp(Str, "weak", 4)) return AT_weak; if (!memcmp(Str, "pure", 4)) return AT_pure; -- cgit v1.2.3