From abf5ad01c3dfadc3d15bd0896689eb37f0df2162 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Wed, 19 Dec 2007 17:43:24 +0000 Subject: [PATCH] Fix the embarassing typo for real this time (- vs _), sorry about breaking the tests Steve. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45202 91177308-0d34-0410-b5e6-96231b3b80d8 --- Sema/SemaDecl.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp index c53ca42efb..e51e1d6549 100644 --- a/Sema/SemaDecl.cpp +++ b/Sema/SemaDecl.cpp @@ -1653,8 +1653,14 @@ void Sema::HandleDeclAttribute(Decl *New, AttributeList *rawAttr) { 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(New)) { QualType newType = HandleVectorTypeAttribute(vDecl->getType(), rawAttr); if (!newType.isNull()) // install the new vector type into the decl @@ -1666,9 +1672,7 @@ void Sema::HandleDeclAttribute(Decl *New, AttributeList *rawAttr) { 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(New)) HandleOCUVectorTypeAttribute(tDecl, rawAttr); else @@ -1797,6 +1801,7 @@ QualType Sema::HandleVectorTypeAttribute(QualType curType, 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")); -- 2.40.0