[cfe-commits] r47418 - in /cfe/trunk: Sema/Sema.h Sema/SemaType.cpp include/clang/Parse/DeclSpec.h
Chris Lattner
sabre at nondot.org
Wed Feb 20 17:07:18 PST 2008
Author: lattner
Date: Wed Feb 20 19:07:18 2008
New Revision: 47418
URL: http://llvm.org/viewvc/llvm-project?rev=47418&view=rev
Log:
move type attribute processing into the creatively named ProcessTypeAttributes method.
Modified:
cfe/trunk/Sema/Sema.h
cfe/trunk/Sema/SemaType.cpp
cfe/trunk/include/clang/Parse/DeclSpec.h
Modified: cfe/trunk/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/Sema.h?rev=47418&r1=47417&r2=47418&view=diff
==============================================================================
--- cfe/trunk/Sema/Sema.h (original)
+++ cfe/trunk/Sema/Sema.h Wed Feb 20 19:07:18 2008
@@ -174,7 +174,9 @@
// Type Analysis / Processing: SemaType.cpp.
//
QualType ConvertDeclSpecToType(DeclSpec &DS);
+ AttributeList *ProcessTypeAttributes(QualType &Result, AttributeList *AL);
QualType GetTypeForDeclarator(Declarator &D, Scope *S);
+
QualType ObjCGetTypeForMethodDefinition(DeclTy *D);
@@ -227,7 +229,7 @@
virtual void ActOnEnumBody(SourceLocation EnumLoc, DeclTy *EnumDecl,
DeclTy **Elements, unsigned NumElements);
private:
- /// Subroutines of ActOnDeclarator()...
+ /// Subroutines of ActOnDeclarator().
TypedefDecl *ParseTypedefDecl(Scope *S, Declarator &D, QualType T,
ScopedDecl *LastDecl);
TypedefDecl *MergeTypeDefDecl(TypedefDecl *New, ScopedDecl *Old);
Modified: cfe/trunk/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaType.cpp?rev=47418&r1=47417&r2=47418&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaType.cpp (original)
+++ cfe/trunk/Sema/SemaType.cpp Wed Feb 20 19:07:18 2008
@@ -142,16 +142,19 @@
// See if there are any attributes on the declspec that apply to the type (as
// opposed to the decl).
- if (!DS.getAttributes())
- return Result;
-
+ if (AttributeList *AL = DS.getAttributes())
+ DS.SetAttributes(ProcessTypeAttributes(Result, AL));
+
+ return Result;
+}
+
+AttributeList *Sema::ProcessTypeAttributes(QualType &Result, AttributeList *AL){
// Scan through and apply attributes to this type where it makes sense. Some
// attributes (such as __address_space__, __vector_size__, etc) apply to the
- // declspec, but others can be present in the decl spec even though they apply
- // to the decl. Here we apply and delete attributes that apply to the
- // declspec and leave the others alone.
+ // type, but others can be present in the type specifiers even though they
+ // apply to the decl. Here we apply and delete attributes that apply to the
+ // type and leave the others alone.
llvm::SmallVector<AttributeList *, 8> LeftOverAttrs;
- AttributeList *AL = DS.getAttributes();
while (AL) {
// Unlink this attribute from the chain, so we can process it independently.
AttributeList *ThisAttr = AL;
@@ -178,10 +181,7 @@
List = LeftOverAttrs[i];
}
- DS.clearAttributes();
- DS.AddAttributes(List);
- //DS.setAttributes(List);
- return Result;
+ return List;
}
/// HandleAddressSpaceTypeAttribute - Process an address_space attribute on the
Modified: cfe/trunk/include/clang/Parse/DeclSpec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/DeclSpec.h?rev=47418&r1=47417&r2=47418&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Parse/DeclSpec.h Wed Feb 20 19:07:18 2008
@@ -258,6 +258,7 @@
alist->addAttributeList(AttrList);
AttrList = alist;
}
+ void SetAttributes(AttributeList *AL) { AttrList = AL; }
AttributeList *getAttributes() const { return AttrList; }
void clearAttributes() { AttrList = 0; }
More information about the cfe-commits
mailing list