[cfe-commits] r45202 - /cfe/trunk/Sema/SemaDecl.cpp

Anders Carlsson andersca at mac.com
Wed Dec 19 09:43:29 PST 2007


Author: andersca
Date: Wed Dec 19 11:43:24 2007
New Revision: 45202

URL: http://llvm.org/viewvc/llvm-project?rev=45202&view=rev
Log:
Fix the embarassing typo for real this time (- vs _), sorry about breaking the tests Steve.

Modified:
    cfe/trunk/Sema/SemaDecl.cpp

Modified: cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=45202&r1=45201&r2=45202&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/Sema/SemaDecl.cpp Wed Dec 19 11:43:24 2007
@@ -1653,8 +1653,14 @@
   const char *attrName = rawAttr->getAttributeName()->getName();
   unsigned attrLen = rawAttr->getAttributeName()->getLength();
   
-  if (!strcmp(rawAttr->getAttributeName()->getName(), "vector_size") ||
-      !strcmp(rawAttr->getAttributeName()->getName(), "__vector_size__")) {
+  // Normalize the attribute name, __foo__ becomes foo.
+  if (attrLen > 4 && attrName[0] == '_' && attrName[1] == '_' &&
+      attrName[attrLen - 2] == '_' && attrName[attrLen - 1] == '_') {
+    attrName += 2;
+    attrLen -= 4;
+  }
+  
+  if (attrLen == 11 && !memcmp(attrName, "vector_size", 11)) {
     if (ValueDecl *vDecl = dyn_cast<ValueDecl>(New)) {
       QualType newType = HandleVectorTypeAttribute(vDecl->getType(), rawAttr);
       if (!newType.isNull()) // install the new vector type into the decl
@@ -1666,9 +1672,7 @@
       if (!newType.isNull()) // install the new vector type into the decl
         tDecl->setUnderlyingType(newType);
     }
-  }
-  if (!strcmp(rawAttr->getAttributeName()->getName(), "ocu_vector_type") ||
-      !strcmp(rawAttr->getAttributeName()->getName(), "__ocu_vector_type__")) {
+  } else if (attrLen == 15 && !memcmp(attrName, "ocu_vector_type", 15)) {
     if (TypedefDecl *tDecl = dyn_cast<TypedefDecl>(New))
       HandleOCUVectorTypeAttribute(tDecl, rawAttr);
     else
@@ -1797,6 +1801,7 @@
 void Sema::HandleAlignedAttribute(Decl *d, AttributeList *rawAttr)
 {
   // check the attribute arguments.
+  // FIXME: Handle the case where are no arguments.
   if (rawAttr->getNumArgs() != 1) {
     Diag(rawAttr->getAttributeLoc(), diag::err_attribute_wrong_number_arguments,
          std::string("1"));





More information about the cfe-commits mailing list