]> granicus.if.org Git - clang/commitdiff
Address comments from Doug - Add a Sema::SemaRef.BuildBlockPointerType and use it.
authorAnders Carlsson <andersca@mac.com>
Fri, 12 Jun 2009 22:56:54 +0000 (22:56 +0000)
committerAnders Carlsson <andersca@mac.com>
Fri, 12 Jun 2009 22:56:54 +0000 (22:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73264 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/Sema.h
lib/Sema/SemaTemplateDeduction.cpp
lib/Sema/SemaTemplateInstantiate.cpp
lib/Sema/SemaType.cpp

index c54b5947f16b5733084156c1314de93f2a7b87bb..09b316286d356f088af77df4e676da8c663c1691 100644 (file)
@@ -352,6 +352,8 @@ public:
   QualType BuildMemberPointerType(QualType T, QualType Class, 
                                   unsigned Quals, SourceLocation Loc, 
                                   DeclarationName Entity);
+  QualType BuildBlockPointerType(QualType T, unsigned Quals,
+                                 SourceLocation Loc, DeclarationName Entity);
   QualType GetTypeForDeclarator(Declarator &D, Scope *S, unsigned Skip = 0,
                                 TagDecl **OwnedDecl = 0);
   DeclarationName GetNameForDeclarator(Declarator &D);
index 48e38ddf14d3112eb091cde3b1f1a24ad4640a56..4bbfd048c2fcc911c1e64821931ffe6c08b49b51 100644 (file)
@@ -497,6 +497,8 @@ DeduceTemplateArguments(ASTContext &Context,
                                      Info, Deduced);
     }
 
+    //     (clang extension)
+    //
     //     type(^)(T) 
     //     T(^)() 
     //     T(^)(T) 
index 6814b36ada48028c507eeaca2069ac8e44395530..1fd11147ed8a866a5fdd8b3ef8c681e8c04e5baf 100644 (file)
@@ -278,9 +278,7 @@ TemplateTypeInstantiator::InstantiateBlockPointerType(const BlockPointerType *T,
   if (PointeeType.isNull())
     return QualType();
   
-  QualType BlockTy = SemaRef.Context.getBlockPointerType(PointeeType);
-  
-  return BlockTy.getQualifiedType(Quals);
+  return SemaRef.BuildBlockPointerType(PointeeType, Quals, Loc, Entity);
 }
 
 QualType
index 6c2a4dc2d0f4faca02e1a6b766d3d9c3bea72d57..70a92706071deecdff02bb54e90e1b39f644e550 100644 (file)
@@ -660,7 +660,33 @@ QualType Sema::BuildMemberPointerType(QualType T, QualType Class,
   return Context.getMemberPointerType(T, Class.getTypePtr())
            .getQualifiedType(Quals);  
 }
-                              
+/// \brief Build a block pointer type.
+///
+/// \param T The type to which we'll be building a block pointer.
+///
+/// \param Quals The cvr-qualifiers to be applied to the block pointer type.
+///
+/// \param Loc The location of the entity whose type involves this
+/// block pointer type or, if there is no such entity, the location of the
+/// type that will have block pointer type.
+///
+/// \param Entity The name of the entity that involves the block pointer
+/// type, if known.
+///
+/// \returns A suitable block pointer type, if there are no
+/// errors. Otherwise, returns a NULL type.
+QualType Sema::BuildBlockPointerType(QualType T, unsigned Quals,
+                                     SourceLocation Loc, 
+                                     DeclarationName Entity) {
+  if (!T.getTypePtr()->isFunctionType()) {
+    Diag(Loc, diag::err_nonfunction_block_type);
+    return QualType();
+  }
+  
+  return Context.getBlockPointerType(T).getQualifiedType(Quals);
+}
+
 /// GetTypeForDeclarator - Convert the type for the specified
 /// declarator to Type instances. Skip the outermost Skip type
 /// objects.
@@ -735,11 +761,8 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S, unsigned Skip,
       if (!LangOpts.Blocks)
         Diag(DeclType.Loc, diag::err_blocks_disable);
         
-      if (!T.getTypePtr()->isFunctionType())
-        Diag(D.getIdentifierLoc(), diag::err_nonfunction_block_type);
-      else
-        T = (Context.getBlockPointerType(T)
-             .getQualifiedType(DeclType.Cls.TypeQuals));
+      T = BuildBlockPointerType(T, DeclType.Cls.TypeQuals, D.getIdentifierLoc(), 
+                                Name);
       break;
     case DeclaratorChunk::Pointer:
       // Verify that we're not building a pointer to pointer to function with