[cfe-commits] r73264 - in /cfe/trunk/lib/Sema: Sema.h SemaTemplateDeduction.cpp SemaTemplateInstantiate.cpp SemaType.cpp
Anders Carlsson
andersca at mac.com
Fri Jun 12 15:56:55 PDT 2009
Author: andersca
Date: Fri Jun 12 17:56:54 2009
New Revision: 73264
URL: http://llvm.org/viewvc/llvm-project?rev=73264&view=rev
Log:
Address comments from Doug - Add a Sema::SemaRef.BuildBlockPointerType and use it.
Modified:
cfe/trunk/lib/Sema/Sema.h
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/lib/Sema/SemaType.cpp
Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=73264&r1=73263&r2=73264&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Fri Jun 12 17:56:54 2009
@@ -352,6 +352,8 @@
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);
Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=73264&r1=73263&r2=73264&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Fri Jun 12 17:56:54 2009
@@ -497,6 +497,8 @@
Info, Deduced);
}
+ // (clang extension)
+ //
// type(^)(T)
// T(^)()
// T(^)(T)
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=73264&r1=73263&r2=73264&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Fri Jun 12 17:56:54 2009
@@ -278,9 +278,7 @@
if (PointeeType.isNull())
return QualType();
- QualType BlockTy = SemaRef.Context.getBlockPointerType(PointeeType);
-
- return BlockTy.getQualifiedType(Quals);
+ return SemaRef.BuildBlockPointerType(PointeeType, Quals, Loc, Entity);
}
QualType
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=73264&r1=73263&r2=73264&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Fri Jun 12 17:56:54 2009
@@ -660,7 +660,33 @@
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 @@
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
More information about the cfe-commits
mailing list