summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-06-12 22:56:54 +0000
committerAnders Carlsson <andersca@mac.com>2009-06-12 22:56:54 +0000
commit15f1dd1c88b77b6ab0f1bbf184087fdb5a10b2d0 (patch)
treebf2a71d993963db1d2cd275a3269233557340550 /clang/lib/Sema
parent170bc42547cacbe6277af2123c718feb60f472e5 (diff)
downloadbcm5719-llvm-15f1dd1c88b77b6ab0f1bbf184087fdb5a10b2d0.tar.gz
bcm5719-llvm-15f1dd1c88b77b6ab0f1bbf184087fdb5a10b2d0.zip
Address comments from Doug - Add a Sema::SemaRef.BuildBlockPointerType and use it.
llvm-svn: 73264
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/Sema.h2
-rw-r--r--clang/lib/Sema/SemaTemplateDeduction.cpp2
-rw-r--r--clang/lib/Sema/SemaTemplateInstantiate.cpp4
-rw-r--r--clang/lib/Sema/SemaType.cpp35
4 files changed, 34 insertions, 9 deletions
diff --git a/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h
index c54b5947f16..09b316286d3 100644
--- a/clang/lib/Sema/Sema.h
+++ b/clang/lib/Sema/Sema.h
@@ -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);
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 48e38ddf14d..4bbfd048c2f 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -497,6 +497,8 @@ DeduceTemplateArguments(ASTContext &Context,
Info, Deduced);
}
+ // (clang extension)
+ //
// type(^)(T)
// T(^)()
// T(^)(T)
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 6814b36ada4..1fd11147ed8 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -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
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 6c2a4dc2d0f..70a92706071 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -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
OpenPOWER on IntegriCloud