diff options
author | Steve Naroff <snaroff@apple.com> | 2008-08-27 16:04:49 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2008-08-27 16:04:49 +0000 |
commit | 5618bd4a52c45fbbb605e3ba885663b2164db8a3 (patch) | |
tree | de48c6a25701bf5c027d7af42054e9a0c25e523b /lib/AST/Type.cpp | |
parent | 30ad167f74cb8a04c35ced6c69b116f15d104f8e (diff) |
First wave of changes to support "blocks" (an extension to C).
This commit adds the declaration syntax (and associated type).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55417 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Type.cpp')
-rw-r--r-- | lib/AST/Type.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 84b369ca30..2c5a3f41bf 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -231,6 +231,20 @@ const PointerType *Type::getAsPointerType() const { return getDesugaredType()->getAsPointerType(); } +const BlockPointerType *Type::getAsBlockPointerType() const { + // If this is directly a block pointer type, return it. + if (const BlockPointerType *PTy = dyn_cast<BlockPointerType>(this)) + return PTy; + + // If the canonical form of this type isn't the right kind, reject it. + if (!isa<BlockPointerType>(CanonicalType)) + return 0; + + // If this is a typedef for a block pointer type, strip the typedef off + // without losing all typedef information. + return getDesugaredType()->getAsBlockPointerType(); +} + const ReferenceType *Type::getAsReferenceType() const { // If this is directly a reference type, return it. if (const ReferenceType *RTy = dyn_cast<ReferenceType>(this)) @@ -574,7 +588,9 @@ bool Type::isScalarType() const { } if (const ASQualType *ASQT = dyn_cast<ASQualType>(CanonicalType)) return ASQT->getBaseType()->isScalarType(); - return isa<PointerType>(CanonicalType) || isa<ComplexType>(CanonicalType) || + return isa<PointerType>(CanonicalType) || + isa<BlockPointerType>(CanonicalType) || + isa<ComplexType>(CanonicalType) || isa<ObjCQualifiedIdType>(CanonicalType); } @@ -831,6 +847,11 @@ void PointerType::getAsStringInternal(std::string &S) const { getPointeeType().getAsStringInternal(S); } +void BlockPointerType::getAsStringInternal(std::string &S) const { + S = '^' + S; + PointeeType.getAsStringInternal(S); +} + void ReferenceType::getAsStringInternal(std::string &S) const { S = '&' + S; |