diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-07-16 19:58:26 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-07-16 19:58:26 +0000 |
commit | 1a1a6e2bd4c5aefd7fd643cf25915f9623a02e59 (patch) | |
tree | 333652f464e28debc770fc4b30bc5b8f74254d28 /lib/Frontend/RewriteBlocks.cpp | |
parent | e41611aa2237d06a0ef61db4528fb2883a8defcd (diff) |
Add member template 'Type::getAs<T>', which converts a Type* to a respective T*.
This method is intended to eventually replace the individual
Type::getAsXXXType<> methods.
The motivation behind this change is twofold:
1) Reduce redundant implementations of Type::getAsXXXType() methods. Most of
them are basically copy-and-paste.
2) By centralizing the implementation of the getAs<Type> logic we can more
smoothly move over to Doug Gregor's proposed canonical type smart pointer
scheme.
Along with this patch:
a) Removed 'Type::getAsPointerType()'; now clients use getAs<PointerType>.
b) Removed 'Type::getAsBlockPointerTypE()'; now clients use getAs<BlockPointerType>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76098 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/RewriteBlocks.cpp')
-rw-r--r-- | lib/Frontend/RewriteBlocks.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/Frontend/RewriteBlocks.cpp b/lib/Frontend/RewriteBlocks.cpp index bc855fa879..a7b5e3d686 100644 --- a/lib/Frontend/RewriteBlocks.cpp +++ b/lib/Frontend/RewriteBlocks.cpp @@ -130,7 +130,7 @@ public: OCT == Context->getCanonicalType(Context->getObjCClassType())) return true; - if (const PointerType *PT = OCT->getAsPointerType()) { + if (const PointerType *PT = OCT->getAs<PointerType>()) { if (isa<ObjCInterfaceType>(PT->getPointeeType()) || PT->getPointeeType()->isObjCQualifiedIdType()) return true; @@ -684,13 +684,13 @@ std::string RewriteBlocks::SynthesizeBlockCall(CallExpr *Exp) { if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Exp->getCallee())) { closureName = DRE->getDecl()->getNameAsCString(); - CPT = DRE->getType()->getAsBlockPointerType(); + CPT = DRE->getType()->getAs<BlockPointerType>(); } else if (BlockDeclRefExpr *CDRE = dyn_cast<BlockDeclRefExpr>(Exp->getCallee())) { closureName = CDRE->getDecl()->getNameAsCString(); - CPT = CDRE->getType()->getAsBlockPointerType(); + CPT = CDRE->getType()->getAs<BlockPointerType>(); } else if (MemberExpr *MExpr = dyn_cast<MemberExpr>(Exp->getCallee())) { closureName = MExpr->getMemberDecl()->getNameAsCString(); - CPT = MExpr->getType()->getAsBlockPointerType(); + CPT = MExpr->getType()->getAs<BlockPointerType>(); } else { assert(1 && "RewriteBlockClass: Bad type"); } @@ -813,11 +813,11 @@ void RewriteBlocks::RewriteBlockPointerFunctionArgs(FunctionDecl *FD) { bool RewriteBlocks::PointerTypeTakesAnyBlockArguments(QualType QT) { const FunctionProtoType *FTP; - const PointerType *PT = QT->getAsPointerType(); + const PointerType *PT = QT->getAs<PointerType>(); if (PT) { FTP = PT->getPointeeType()->getAsFunctionProtoType(); } else { - const BlockPointerType *BPT = QT->getAsBlockPointerType(); + const BlockPointerType *BPT = QT->getAs<BlockPointerType>(); assert(BPT && "BlockPointerTypeTakeAnyBlockArguments(): not a block pointer type"); FTP = BPT->getPointeeType()->getAsFunctionProtoType(); } @@ -1068,7 +1068,7 @@ void RewriteBlocks::RewriteFunctionProtoType(QualType funcType, NamedDecl *D) { } void RewriteBlocks::CheckFunctionPointerDecl(QualType funcType, NamedDecl *ND) { - const PointerType *PT = funcType->getAsPointerType(); + const PointerType *PT = funcType->getAs<PointerType>(); if (PT && PointerTypeTakesAnyBlockArguments(funcType)) RewriteFunctionProtoType(PT->getPointeeType(), ND); } |