[cfe-commits] r45195 - in /cfe/trunk/Sema: Sema.h SemaDecl.cpp
Anders Carlsson
andersca at mac.com
Tue Dec 18 23:19:41 PST 2007
Author: andersca
Date: Wed Dec 19 01:19:40 2007
New Revision: 45195
URL: http://llvm.org/viewvc/llvm-project?rev=45195&view=rev
Log:
Fix an embarassing typo and add some very limited support for the aligned attribute.
Modified:
cfe/trunk/Sema/Sema.h
cfe/trunk/Sema/SemaDecl.cpp
Modified: cfe/trunk/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/Sema.h?rev=45195&r1=45194&r2=45195&view=diff
==============================================================================
--- cfe/trunk/Sema/Sema.h (original)
+++ cfe/trunk/Sema/Sema.h Wed Dec 19 01:19:40 2007
@@ -250,6 +250,8 @@
QualType HandleVectorTypeAttribute(QualType curType, AttributeList *rawAttr);
void HandleOCUVectorTypeAttribute(TypedefDecl *d, AttributeList *rawAttr);
+ void HandleAlignedAttribute(Decl *d, AttributeList *rawAttr);
+
/// CheckProtocolMethodDefs - This routine checks unimpletented methods
/// Declared in protocol, and those referenced by it.
void CheckProtocolMethodDefs(ObjcProtocolDecl *PDecl,
Modified: cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=45195&r1=45194&r2=45195&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/Sema/SemaDecl.cpp Wed Dec 19 01:19:40 2007
@@ -1678,7 +1678,10 @@
else
Diag(rawAttr->getAttributeLoc(),
diag::err_typecheck_ocu_vector_not_typedef);
+ } else if (attrLen == 7 && !memcmp(attrName, "aligned", 7)) {
+ HandleAlignedAttribute(New, rawAttr);
}
+
// FIXME: add other attributes...
}
@@ -1697,7 +1700,7 @@
void Sema::HandleOCUVectorTypeAttribute(TypedefDecl *tDecl,
AttributeList *rawAttr) {
QualType curType = tDecl->getUnderlyingType();
- // check the attribute arugments.
+ // check the attribute arguments.
if (rawAttr->getNumArgs() != 1) {
Diag(rawAttr->getAttributeLoc(), diag::err_attribute_wrong_number_arguments,
std::string("1"));
@@ -1795,3 +1798,20 @@
return Context.getVectorType(curType, vectorSize/typeSize);
}
+void Sema::HandleAlignedAttribute(Decl *d, AttributeList *rawAttr)
+{
+ // check the attribute arguments.
+ if (rawAttr->getNumArgs() != 1) {
+ Diag(rawAttr->getAttributeLoc(), diag::err_attribute_wrong_number_arguments,
+ std::string("1"));
+ return;
+ }
+
+ Expr *alignmentExpr = static_cast<Expr *>(rawAttr->getArg(0));
+ llvm::APSInt alignment(32);
+ if (!alignmentExpr->isIntegerConstantExpr(alignment, Context)) {
+ Diag(rawAttr->getAttributeLoc(), diag::err_attribute_vector_size_not_int,
+ alignmentExpr->getSourceRange());
+ return;
+ }
+}
More information about the cfe-commits
mailing list