]> granicus.if.org Git - clang/commitdiff
move type attribute processing into the creatively named ProcessTypeAttributes method.
authorChris Lattner <sabre@nondot.org>
Thu, 21 Feb 2008 01:07:18 +0000 (01:07 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 21 Feb 2008 01:07:18 +0000 (01:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47418 91177308-0d34-0410-b5e6-96231b3b80d8

Sema/Sema.h
Sema/SemaType.cpp
include/clang/Parse/DeclSpec.h

index e33a3cb18ba3406fe99f45d1605e239d98f2bfdf..70f76cc2fe3c71d70559655ec3b73cf0b7f2bd91 100644 (file)
@@ -174,7 +174,9 @@ public:
   // 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 @@ private:
   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);
index 2002bd371914e612455ae2caff2de759b969d124..e5477c030d7a115456662a588abebacd1964b6b6 100644 (file)
@@ -142,16 +142,19 @@ QualType Sema::ConvertDeclSpecToType(DeclSpec &DS) {
   
   // 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 @@ QualType Sema::ConvertDeclSpecToType(DeclSpec &DS) {
     List = LeftOverAttrs[i];
   }
   
-  DS.clearAttributes();
-  DS.AddAttributes(List);
-  //DS.setAttributes(List);
-  return Result;
+  return List;
 }
 
 /// HandleAddressSpaceTypeAttribute - Process an address_space attribute on the
index 8c07f6f92f588870a013ffe5494a3924522c7800..2eb2364ad984bf0a3e6da580029ff955a6279c61 100644 (file)
@@ -258,6 +258,7 @@ public:
       alist->addAttributeList(AttrList); 
     AttrList = alist;
   }
+  void SetAttributes(AttributeList *AL) { AttrList = AL; }
   AttributeList *getAttributes() const { return AttrList; }
   void clearAttributes() { AttrList = 0; }