Collect and build and process type attributes on pointers.  For 
example, we can now correctly build the type for things like:
    _AS1 float * _AS2 *B;



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47420 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp
index 9db0e01..e0a42a2 100644
--- a/Sema/SemaDecl.cpp
+++ b/Sema/SemaDecl.cpp
@@ -732,8 +732,8 @@
     FunctionDecl *NewFD = new FunctionDecl(D.getIdentifierLoc(), II, R, SC,
                                            D.getDeclSpec().isInlineSpecified(),
                                            LastDeclarator);
-    // FIXME: Handle attributes.
-    D.getDeclSpec().clearAttributes();
+    // FIXME: Handle attributes: should delete anything left.
+    D.getDeclSpec().SetAttributes(0);
     
     // Merge the decl with the existing one if appropriate. Since C functions
     // are in a flat namespace, make sure we consider decls in outer scopes.
diff --git a/Sema/SemaType.cpp b/Sema/SemaType.cpp
index 45bae6d..4b06e6a 100644
--- a/Sema/SemaType.cpp
+++ b/Sema/SemaType.cpp
@@ -100,7 +100,7 @@
       Action::DeclTy **PPDecl = &(*DS.getProtocolQualifiers())[0];
       Result = Context.getObjCQualifiedInterfaceType(ObjCIntDecl,
                                    reinterpret_cast<ObjCProtocolDecl**>(PPDecl),
-                                                    DS.NumProtocolQualifiers());
+                                                 DS.getNumProtocolQualifiers());
       break;
     }
     else if (TypedefDecl *typeDecl = dyn_cast<TypedefDecl>(D)) {
@@ -110,7 +110,7 @@
         Action::DeclTy **PPDecl = &(*DS.getProtocolQualifiers())[0];
         Result = Context.getObjCQualifiedIdType(typeDecl->getUnderlyingType(),
                                  reinterpret_cast<ObjCProtocolDecl**>(PPDecl),
-                                            DS.NumProtocolQualifiers());
+                                            DS.getNumProtocolQualifiers());
         break;
       }
     }
@@ -164,7 +164,7 @@
   // Walk the DeclTypeInfo, building the recursive type as we go.  DeclTypeInfos
   // are ordered from the identifier out, which is opposite of what we want :).
   for (unsigned i = 0, e = D.getNumTypeObjects(); i != e; ++i) {
-    const DeclaratorChunk &DeclType = D.getTypeObject(e-i-1);
+    DeclaratorChunk &DeclType = D.getTypeObject(e-i-1);
     switch (DeclType.Kind) {
     default: assert(0 && "Unknown decltype!");
     case DeclaratorChunk::Pointer:
@@ -178,6 +178,11 @@
 
       // Apply the pointer typequals to the pointer object.
       T = Context.getPointerType(T).getQualifiedType(DeclType.Ptr.TypeQuals);
+        
+      // See if there are any attributes on the pointer that apply to it.
+      if (AttributeList *AL = DeclType.Ptr.AttrList)
+        DeclType.Ptr.AttrList = ProcessTypeAttributes(T, AL);
+        
       break;
     case DeclaratorChunk::Reference:
       if (const ReferenceType *RT = T->getAsReferenceType()) {
@@ -190,6 +195,10 @@
       }
 
       T = Context.getReferenceType(T);
+        
+      // See if there are any attributes on the pointer that apply to it.
+      if (AttributeList *AL = DeclType.Ref.AttrList)
+        DeclType.Ref.AttrList = ProcessTypeAttributes(T, AL);
       break;
     case DeclaratorChunk::Array: {
       const DeclaratorChunk::ArrayTypeInfo &ATI = DeclType.Arr;