[cfe-commits] r52874 - in /cfe/trunk/lib/Sema: Sema.h SemaDecl.cpp SemaDeclAttr.cpp

Chris Lattner sabre at nondot.org
Sat Jun 28 16:58:56 PDT 2008


Author: lattner
Date: Sat Jun 28 18:58:55 2008
New Revision: 52874

URL: http://llvm.org/viewvc/llvm-project?rev=52874&view=rev
Log:
more attribute refactoring/renaming, no functionality change.

Modified:
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=52874&r1=52873&r2=52874&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Sat Jun 28 18:58:55 2008
@@ -301,9 +301,10 @@
   ScopedDecl *ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II,
                                  Scope *S);
   // Decl attributes - this routine is the top level dispatcher. 
-  void HandleDeclAttributes(Decl *New, const AttributeList *DeclSpecAttrs,
-                            const AttributeList *DeclaratorAttrs);
-  void HandleDeclAttribute(Decl *New, const AttributeList &Attr);
+  void ProcessDeclAttributes(Decl *New, const AttributeList *DeclSpecAttrs,
+                             const AttributeList *DeclaratorAttrs);
+  void ProcessDeclAttributeList(Decl *D, const AttributeList *AttrList);
+  void ProcessDeclAttribute(Decl *D, const AttributeList &Attr);
 
   /// HandleAddressSpaceTypeAttribute - this attribute is only applicable to 
   /// objects without automatic storage duration. 

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat Jun 28 18:58:55 2008
@@ -612,8 +612,8 @@
     if (!NewTD) return 0;
 
     // Handle attributes prior to checking for duplicates in MergeVarDecl
-    HandleDeclAttributes(NewTD, D.getDeclSpec().getAttributes(),
-                         D.getAttributes());
+    ProcessDeclAttributes(NewTD, D.getDeclSpec().getAttributes(),
+                          D.getAttributes());
     // Merge the decl with the existing one if appropriate. If the decl is
     // in an outer scope, it isn't the same thing.
     if (PrevDecl && IdResolver.isDeclInScope(PrevDecl, CurContext, S)) {
@@ -652,8 +652,8 @@
                                                II, R, SC, isInline,
                                                LastDeclarator);
     // Handle attributes.
-    HandleDeclAttributes(NewFD, D.getDeclSpec().getAttributes(),
-                         D.getAttributes());
+    ProcessDeclAttributes(NewFD, D.getDeclSpec().getAttributes(),
+                          D.getAttributes());
 
     // Copy the parameter declarations from the declarator D to
     // the function declaration NewFD, if they are available.
@@ -745,8 +745,8 @@
                               II, R, SC, LastDeclarator);
     }
     // Handle attributes prior to checking for duplicates in MergeVarDecl
-    HandleDeclAttributes(NewVD, D.getDeclSpec().getAttributes(),
-                         D.getAttributes());
+    ProcessDeclAttributes(NewVD, D.getDeclSpec().getAttributes(),
+                          D.getAttributes());
 
     // Emit an error if an address space was applied to decl with local storage.
     // This includes arrays of objects with address space qualifiers, but not
@@ -1456,8 +1456,8 @@
   if (II)
     PushOnScopeChains(New, S);
 
-  HandleDeclAttributes(New, D.getDeclSpec().getAttributes(),
-                       D.getAttributes());
+  ProcessDeclAttributes(New, D.getDeclSpec().getAttributes(),
+                        D.getAttributes());
   return New;
 
 }
@@ -1725,7 +1725,8 @@
     PushOnScopeChains(New, S);
   }
   
-  HandleDeclAttributes(New, Attr, 0);
+  if (Attr)
+    ProcessDeclAttributeList(New, Attr);
   return New;
 }
 
@@ -1848,8 +1849,8 @@
   // FIXME: Chain fielddecls together.
   FieldDecl *NewFD = FieldDecl::Create(Context, Loc, II, T, BitWidth);
   
-  HandleDeclAttributes(NewFD, D.getDeclSpec().getAttributes(),
-                       D.getAttributes());
+  ProcessDeclAttributes(NewFD, D.getDeclSpec().getAttributes(),
+                        D.getAttributes());
 
   if (D.getInvalidType() || InvalidDecl)
     NewFD->setInvalidDecl();
@@ -1912,8 +1913,8 @@
   
   ObjCIvarDecl *NewID = ObjCIvarDecl::Create(Context, Loc, II, T);
   
-  HandleDeclAttributes(NewID, D.getDeclSpec().getAttributes(),
-                       D.getAttributes());
+  ProcessDeclAttributes(NewID, D.getDeclSpec().getAttributes(),
+                        D.getAttributes());
   
   if (D.getInvalidType() || InvalidDecl)
     NewID->setInvalidDecl();

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=52874&r1=52873&r2=52874&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Sat Jun 28 18:58:55 2008
@@ -54,62 +54,65 @@
          ClsName == &Ctx.Idents.get("NSMutableString");
 }
 
-void Sema::HandleDeclAttributes(Decl *New, const AttributeList *DeclSpecAttrs,
-                                const AttributeList *DeclaratorAttrs) {
+void Sema::ProcessDeclAttributes(Decl *D, const AttributeList *DeclSpecAttrs,
+                                 const AttributeList *DeclaratorAttrs) {
   if (DeclSpecAttrs == 0 && DeclaratorAttrs == 0) return;
-  
-  while (DeclSpecAttrs) {
-    HandleDeclAttribute(New, *DeclSpecAttrs);
-    DeclSpecAttrs = DeclSpecAttrs->getNext();
-  }
+
+  ProcessDeclAttributeList(D, DeclSpecAttrs);
   
   // If there are any type attributes that were in the declarator, apply them to
   // its top level type.
-  if (ValueDecl *VD = dyn_cast<ValueDecl>(New)) {
+  if (ValueDecl *VD = dyn_cast<ValueDecl>(D)) {
     QualType DT = VD->getType();
     ProcessTypeAttributes(DT, DeclaratorAttrs);
     VD->setType(DT);
-  } else if (TypedefDecl *TD = dyn_cast<TypedefDecl>(New)) {
+  } else if (TypedefDecl *TD = dyn_cast<TypedefDecl>(D)) {
     QualType DT = TD->getUnderlyingType();
     ProcessTypeAttributes(DT, DeclaratorAttrs);
     TD->setUnderlyingType(DT);
   }
   
-  while (DeclaratorAttrs) {
-    HandleDeclAttribute(New, *DeclaratorAttrs);
-    DeclaratorAttrs = DeclaratorAttrs->getNext();
+  ProcessDeclAttributeList(D, DeclaratorAttrs);
+}
+
+/// ProcessDeclAttributeList - Apply all the decl attributes in the specified
+/// attribute list to the specified decl, ignoring any type attributes.
+void Sema::ProcessDeclAttributeList(Decl *D, const AttributeList *AttrList) {
+  while (AttrList) {
+    ProcessDeclAttribute(D, *AttrList);
+    AttrList = AttrList->getNext();
   }
 }
 
 /// HandleDeclAttribute - Apply the specific attribute to the specified decl if
 /// the attribute applies to decls.  If the attribute is a type attribute, just
 /// silently ignore it.
-void Sema::HandleDeclAttribute(Decl *New, const AttributeList &Attr) {
+void Sema::ProcessDeclAttribute(Decl *D, const AttributeList &Attr) {
   switch (Attr.getKind()) {
   case AttributeList::AT_address_space:
     // Ignore this, this is a type attribute, handled by ProcessTypeAttributes.
     break;
-  case AttributeList::AT_vector_size:HandleVectorSizeAttribute(New, Attr);break;
-  case AttributeList::AT_ext_vector_type:
-    HandleExtVectorTypeAttribute(New, Attr);
-    break;
-  case AttributeList::AT_mode:       HandleModeAttribute(New, Attr);  break;
-  case AttributeList::AT_alias:      HandleAliasAttribute(New, Attr); break;
-  case AttributeList::AT_deprecated: HandleDeprecatedAttribute(New, Attr);break;
-  case AttributeList::AT_visibility: HandleVisibilityAttribute(New, Attr);break;
-  case AttributeList::AT_weak:       HandleWeakAttribute(New, Attr); break;
-  case AttributeList::AT_dllimport:  HandleDLLImportAttribute(New, Attr); break;
-  case AttributeList::AT_dllexport:  HandleDLLExportAttribute(New, Attr); break;
-  case AttributeList::AT_nothrow:    HandleNothrowAttribute(New, Attr); break;
-  case AttributeList::AT_stdcall:    HandleStdCallAttribute(New, Attr); break;
-  case AttributeList::AT_fastcall:   HandleFastCallAttribute(New, Attr); break;
-  case AttributeList::AT_aligned:    HandleAlignedAttribute(New, Attr); break;
-  case AttributeList::AT_packed:     HandlePackedAttribute(New, Attr); break;
-  case AttributeList::AT_annotate:   HandleAnnotateAttribute(New, Attr); break;
-  case AttributeList::AT_noreturn:   HandleNoReturnAttribute(New, Attr); break;
-  case AttributeList::AT_format:     HandleFormatAttribute(New, Attr); break;
+  case AttributeList::AT_vector_size: HandleVectorSizeAttribute(D, Attr); break;
+  case AttributeList::AT_ext_vector_type: 
+    HandleExtVectorTypeAttribute(D, Attr);
+    break;
+  case AttributeList::AT_mode:       HandleModeAttribute(D, Attr);  break;
+  case AttributeList::AT_alias:      HandleAliasAttribute(D, Attr); break;
+  case AttributeList::AT_deprecated: HandleDeprecatedAttribute(D, Attr);break;
+  case AttributeList::AT_visibility: HandleVisibilityAttribute(D, Attr);break;
+  case AttributeList::AT_weak:       HandleWeakAttribute(D, Attr); break;
+  case AttributeList::AT_dllimport:  HandleDLLImportAttribute(D, Attr); break;
+  case AttributeList::AT_dllexport:  HandleDLLExportAttribute(D, Attr); break;
+  case AttributeList::AT_nothrow:    HandleNothrowAttribute(D, Attr); break;
+  case AttributeList::AT_stdcall:    HandleStdCallAttribute(D, Attr); break;
+  case AttributeList::AT_fastcall:   HandleFastCallAttribute(D, Attr); break;
+  case AttributeList::AT_aligned:    HandleAlignedAttribute(D, Attr); break;
+  case AttributeList::AT_packed:     HandlePackedAttribute(D, Attr); break;
+  case AttributeList::AT_annotate:   HandleAnnotateAttribute(D, Attr); break;
+  case AttributeList::AT_noreturn:   HandleNoReturnAttribute(D, Attr); break;
+  case AttributeList::AT_format:     HandleFormatAttribute(D, Attr); break;
   case AttributeList::AT_transparent_union:
-    HandleTransparentUnionAttribute(New, Attr);
+    HandleTransparentUnionAttribute(D, Attr);
     break;
   default:
 #if 0





More information about the cfe-commits mailing list