[cfe-commits] r84339 - /cfe/trunk/lib/Parse/AttributeList.cpp

Daniel Dunbar daniel at zuster.org
Sat Oct 17 11:12:29 PDT 2009


Author: ddunbar
Date: Sat Oct 17 13:12:29 2009
New Revision: 84339

URL: http://llvm.org/viewvc/llvm-project?rev=84339&view=rev
Log:
Rewrite AttributeList::getKind to use StringRef API.

Modified:
    cfe/trunk/lib/Parse/AttributeList.cpp

Modified: cfe/trunk/lib/Parse/AttributeList.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/AttributeList.cpp?rev=84339&r1=84338&r2=84339&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/AttributeList.cpp (original)
+++ cfe/trunk/lib/Parse/AttributeList.cpp Sat Oct 17 13:12:29 2009
@@ -45,18 +45,15 @@
 }
 
 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;





More information about the cfe-commits mailing list